123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.FinancialManagement.SetSmallForm
- {
- public partial class StorefrontOutlaySetSmallForm : LYFZ.Software.UI.FinancialManagement.SetSmallForm.StorefrontOutlayEnterSetSmallForm
- {
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- LYFZ.BLL.BLL_ErpSystemCategory scbll = new BLL.BLL_ErpSystemCategory();
- LYFZ.BLL.BLL_ErpOtherIncomeAndExpenses oiebll = new BLL.BLL_ErpOtherIncomeAndExpenses();
- public StorefrontOutlaySetSmallForm()
- {
- this.Load += StorefrontOutlaySetSmallForm_Load;
- this.Shown += StorefrontOutlaySetSmallForm_Shown;
- this.btnSave.Click += btnSave_Click;
- this.btnCancel.Click += btnCancel_Click;
- this.btnSet.Click += btnSet_Click;
- this.btnSetPay.Click += btnSetPay_Click;
- this.btnUpdateTime.Click += btnUpdateTime_Click;
- this.btnSelect.Click += btnSelect_Click;
- this.btnDelete.Click += btnDelete_Click;
- this.pictPhoto.MouseDoubleClick += pictPhoto_MouseDoubleClick;
- this.txtOiae_Money.KeyPress += txtOiae_Money_KeyPress;
- }
- public enum OutlayLoadType
- {
- 店面支出,
- 财务支出
- }
- public enum OutlayInputType
- {
- 添加,
- 修改
- }
- public int OutlayID = 0;
- public OutlayLoadType EnumOutlayLoadType;
- public OutlayInputType EnumOutlayInputType;
- public bool IsSaveed = false;
- string StrUserName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name;
- string StrUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- string StrServerPath = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.TCP_FinancialOutlayReceipt();
-
-
-
-
-
- void StorefrontOutlaySetSmallForm_Load(object sender, EventArgs e)
- {
- switch (EnumOutlayInputType)
- {
- case OutlayInputType.添加:
-
-
- break;
- case OutlayInputType.修改:
- break;
- }
- }
-
-
-
-
-
- void StorefrontOutlaySetSmallForm_Shown(object sender, EventArgs e)
- {
-
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_DepartmentAndEmployee(this.txtTsorder_OpenSingle, IsFirstNodeNull: true, IsShowResign: false);
-
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_PaymentMethod(this.cmbPay_PaymentMethod, IsShowAll: false);
-
- switch (EnumOutlayLoadType)
- {
- case OutlayLoadType.财务支出:
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BFAGBGBAEJBACEEHJ", this.CtvTsorder_Name, IsFirstNodeNull: false);
- break;
- case OutlayLoadType.店面支出:
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BEBACIAFBEDIGJJFE", this.CtvTsorder_Name, IsFirstNodeNull: false);
- break;
- }
- this.txtOiae_IEDatetime.Text = SDateTime.Now.ToString();
- this.txtOiae_PersonHandling.Text = this.StrUserName;
- LYFZ.Model.Model_ErpOtherIncomeAndExpenses model = oiebll.GetModel(this.OutlayID);
- if (model.ID > 0)
- {
- this.btnUpdateTime.Visible = false;
- this.CtvTsorder_Name.TextFindTag(model.Oiae_ProjectName);
- this.txtTsorder_OpenSingle.TagFindText(model.Oiae_ThePayer);
- this.txtOiae_Money.Text = model.Oiae_Money.ToString("n2");
- this.txtOiae_IEDatetime.Text = LYFZ.Command.Command_Validate.DateTimeToString(model.Oiae_IEDatetime);
- this.txtOiae_IEDatetime.Tag = model.Oiae_IEDatetime;
- this.txtOiae_PersonHandling.Text = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(model.Oiae_PersonHandling)["User_Name"].ToString().Trim();
- this.txtOiae_Remark.Text = model.Oiae_Remark;
- this.cmbPay_PaymentMethod.TagFindText(model.Oiae_PaymentMethod);
- if (!string.IsNullOrEmpty(model.Oiae_Invoice))
- {
- this.pictPhoto.BeginInvoke((Action)delegate()
- { this.pictPhoto.Image = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetImage(LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.StringToByte(model.Oiae_Invoice)); });
- }
- else
- {
- System.Threading.ThreadPool.QueueUserWorkItem(delegate
- {
- string retmsg = "";
- Bitmap retBmp_Jobs = null;
- try
- {
- retmsg = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.TcpClient.DownloadBitmap(ref retBmp_Jobs, StrServerPath + "\\" + model.ID + ".jpg");
- }
- catch (Exception ex)
- { retmsg = ex.Message; }
- this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
- {
- try
- { this.pictPhoto.Image = retBmp_Jobs; }
- catch
- { }
- }));
- });
- }
- }
-
- List<Control> hideControl = new List<Control>();
- hideControl.Add(cmbPay_PaymentMethod);
- LYFZ.Software.MainBusiness.VersionControl.StaticVersion.BindVersionShowHideControl(VersionControl.VersionFunctionEnum.财务管理扫码支付, hideControl, null, null);
- }
-
-
-
-
-
- void btnSave_Click(object sender, EventArgs e)
- {
- #region 判断不能为空
- if (string.IsNullOrEmpty(this.CtvTsorder_Name.Text))
- { MessageBoxCustom.Show("项目名称不能为空!"); return; }
- if (string.IsNullOrEmpty(this.cmbPay_PaymentMethod.Text))
- { MessageBoxCustom.Show("支付方式不能为空!"); return; }
- if (string.IsNullOrEmpty(this.txtOiae_Money.Text))
- { MessageBoxCustom.Show("金额不能为空!"); return; }
- try
- {
- Convert.ToDecimal(this.txtOiae_Money.Text);
- }
- catch (Exception ex)
- { MessageBoxCustom.Show("金额输入不正确定!" + ex.Message.Trim()); }
- if (string.IsNullOrEmpty(this.txtOiae_IEDatetime.DateValue))
- { MessageBoxCustom.Show("日期不能为空!"); return; }
- if (string.IsNullOrEmpty(this.txtTsorder_OpenSingle.Text))
- { MessageBoxCustom.Show("经手人不能为空!"); return; }
- #endregion
- LYFZ.Model.Model_ErpOtherIncomeAndExpenses model = null;
- if (this.OutlayID <= 0)
- {
- DateTime StrTime = SDateTime.Now;
- model = new Model.Model_ErpOtherIncomeAndExpenses();
- switch (this.EnumOutlayLoadType)
- {
- case OutlayLoadType.财务支出: model.Oiae_Type = "财务支出"; break;
- case OutlayLoadType.店面支出: model.Oiae_Type = "支出"; break;
- }
- model.Oiae_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- model.Oiae_ProjectName = this.CtvTsorder_Name.Text.Trim();
- model.Oiae_Money = Convert.ToDecimal(this.txtOiae_Money.Text);
- model.Oiae_IEDatetime = Convert.ToDateTime(this.txtOiae_IEDatetime.DateTimeValue);
- model.Oiae_PersonHandling = this.StrUserID;
- if (string.IsNullOrEmpty(this.txtTsorder_OpenSingle.Text.Trim()))
- { model.Oiae_ThePayer = ""; }
- else
- { model.Oiae_ThePayer = this.txtTsorder_OpenSingle.Tag.ToString().Trim(); }
- model.Oiae_Invoice = "";
- model.Oiae_SourceType = 0;
- model.Oiae_OrderNumber = "";
- model.Oiae_Remark = this.txtOiae_Remark.Text.Trim();
- model.Oiae_CreateDateTime = StrTime;
- model.Oiae_PaymentMethod = this.cmbPay_PaymentMethod.Tag.ToString();
- model.Oiae_FinancialAuditState = "未审核";
- model.Oiae_ManagerAuditState = "未审核";
- model.Oiae_CEOAuditState = "未审核";
- if (oiebll.Add(model))
- {
- this.IsSaveed = true;
- DataTable tbl = orbll.GetView_Custom("tb_ErpOtherIncomeAndExpenses", StrWhere: "Oiae_ProjectName = '" + this.CtvTsorder_Name.Text.Trim() + "' And Oiae_IEDatetime = '" + this.txtOiae_IEDatetime.DateTimeValue + "' And Oiae_CreateDateTime = '" + StrTime.ToString("yyyy-MM-dd HH:mm:ss.fff") + "' And Oiae_PersonHandling = '" + this.StrUserID + "'", ShowColumnName: "ID").Tables[0];
- if (tbl.Rows.Count > 0)
- { this.UpDataPhotoImage(tbl.Rows[0]["ID"].ToString().Trim()); }
- MessageBoxCustom.Show("保存成功!可继续录入资料!");
- this.CtvTsorder_Name.Text = "";
- this.txtTsorder_OpenSingle.Text = "";
- this.txtOiae_Money.Text = "";
- this.txtOiae_IEDatetime.Text = "";
- this.txtOiae_IEDatetime.Tag = null;
- this.txtOiae_Remark.Text = "";
- }
- else
- { MessageBoxCustom.Show("保存失败!"); }
- }
- else
- {
- model = oiebll.GetModel(this.OutlayID);
- model.Oiae_ProjectName = this.CtvTsorder_Name.Text;
- model.Oiae_Money = Convert.ToDecimal(this.txtOiae_Money.Text);
- if (Convert.ToDateTime(this.txtOiae_IEDatetime.Tag).ToString("yyyy-MM-dd") != this.txtOiae_IEDatetime.DateValue.Trim())
- { model.Oiae_IEDatetime = Convert.ToDateTime(this.txtOiae_IEDatetime.DateTimeValue); }
- if (string.IsNullOrEmpty(this.txtTsorder_OpenSingle.Text))
- { model.Oiae_ThePayer = ""; }
- else
- { model.Oiae_ThePayer = this.txtTsorder_OpenSingle.Tag.ToString(); }
- model.Oiae_Invoice = "";
- model.Oiae_Remark = this.txtOiae_Remark.Text;
-
- model.Oiae_PaymentMethod = this.cmbPay_PaymentMethod.Tag.ToString();
- model.Oiae_UpdateDateTime = SDateTime.Now;
- model.Oiae_UpdateName = StrUserID;
- if (oiebll.Update(model))
- {
- this.UpDataPhotoImage(model.ID.ToString().Trim());
- this.IsSaveed = true;
- MessageBoxCustom.Show("修改成功!");
- }
- else
- { MessageBoxCustom.Show("修改失败!"); }
- }
- }
- void UpDataPhotoImage(string StrID)
- {
- if (this.pictPhoto.Image != null)
- {
- if (this.labelEx6.ForeColor == Color.Red)
- {
- Bitmap bmp = new Bitmap(this.pictPhoto.Image);
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- backgroundWorker.ReportProgress(0, "正在连接服务器...");
- try
- {
- string ret = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.TcpClient.UploadFileToServer(bmp, System.Drawing.Imaging.ImageFormat.Jpeg, StrServerPath + "\\" + StrID + ".jpg", backgroundWorker);
- if (ret.IndexOf("成功") == -1)
- { MessageBoxCustom.Show(ret, backgroundWorker: backgroundWorker); return; }
- }
- catch
- { }
- });
- }
- }
- else if (this.IsDeletePhoto)
- {
- try
- {
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- { string ret = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.TcpClient.DeleteFile(StrServerPath + "\\" + StrID + ".jpg", backgroundWorker); });
- }
- catch
- { }
- this.IsDeletePhoto = false;
- }
- this.labelEx6.ForeColor = System.Drawing.Color.FromArgb(119, 113, 114);
- }
-
-
-
-
-
- void btnCancel_Click(object sender, EventArgs e)
- { this.Close(); }
-
-
-
-
-
- void btnSet_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet frm = new InitialSet.FrmSystemSet();
- switch (EnumOutlayLoadType)
- {
- case OutlayLoadType.财务支出:
- frm.TypeName = "BFAGBGBAEJBACEEHJ";
- frm.Version = "Version";
- if (frm.ShowDialog() == DialogResult.OK)
- { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BFAGBGBAEJBACEEHJ", this.CtvTsorder_Name, IsFirstNodeNull: false); }
- break;
- case OutlayLoadType.店面支出:
- frm.TypeName = "BEBACIAFBEDIGJJFE";
- frm.Version = "Version";
- if (frm.ShowDialog() == DialogResult.OK)
- { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BEBACIAFBEDIGJJFE", this.CtvTsorder_Name, IsFirstNodeNull: false); }
- break;
- }
- }
-
-
-
-
-
- void btnSetPay_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet frm = new InitialSet.FrmSystemSet();
- frm.TypeName = "BEBACCAFCCEAGAIHH";
- frm.Version = "Version";
- if (frm.ShowDialog() == DialogResult.OK)
- { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_PaymentMethod(this.txtTsorder_OpenSingle, IsShowAll: false); }
- }
-
-
-
-
-
- void btnUpdateTime_Click(object sender, EventArgs e)
- {
- switch (EnumOutlayLoadType)
- {
- case OutlayLoadType.财务支出:
- if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.FinancialExpensesCompetence, CustomAttributes.OperatingAuthority.UpdatePaymentTime))
- { this.txtOiae_IEDatetime.Enabled = true; }
- else
- {
- LYFZ.Software.MainBusiness.DoorCityProcess.SuperSmallForm.AuthorizeLoginSuperSmallForm frm = new DoorCityProcess.SuperSmallForm.AuthorizeLoginSuperSmallForm("FinancialExpensesCompetence", CustomAttributes.OperatingAuthority.UpdatePaymentTime);
- if (frm.ShowDialog() == DialogResult.OK)
- {
- if (LYFZ.BLL.BLL_ErpUser.GetRights(frm.CurrentAuthorizeUserRights.FinancialExpensesCompetence, CustomAttributes.OperatingAuthority.UpdatePaymentTime, frm.User_BelongRoles))
- {
- frm.SetAuthorizationResult();
- this.txtOiae_IEDatetime.Enabled = true; }
- else {
- frm.SetAuthorizationResult(String.Format("授权失败,授权人没有'{0}'权限", LYFZ.Software.MainBusiness.DoorCityProcess.SuperSmallForm.AuthorizeLoginSuperSmallForm.ConvertEnumToDescription(CustomAttributes.OperatingAuthority.UpdatePaymentTime).ToString()));
- }
- }
- }
- break;
- case OutlayLoadType.店面支出:
- if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.CashExpendituresCompetence, CustomAttributes.OperatingAuthority.UpdatePaymentTime))
- { this.txtOiae_IEDatetime.Enabled = true; }
- else
- {
- LYFZ.Software.MainBusiness.DoorCityProcess.SuperSmallForm.AuthorizeLoginSuperSmallForm frm = new DoorCityProcess.SuperSmallForm.AuthorizeLoginSuperSmallForm("CashExpendituresCompetence", CustomAttributes.OperatingAuthority.UpdatePaymentTime);
- if (frm.ShowDialog() == DialogResult.OK)
- {
- if (LYFZ.BLL.BLL_ErpUser.GetRights(frm.CurrentAuthorizeUserRights.CashExpendituresCompetence, CustomAttributes.OperatingAuthority.UpdatePaymentTime, frm.User_BelongRoles))
- {
- frm.SetAuthorizationResult();
- this.txtOiae_IEDatetime.Enabled = true; }
- else {
- frm.SetAuthorizationResult(String.Format("授权失败,授权人没有'{0}'权限", LYFZ.Software.MainBusiness.DoorCityProcess.SuperSmallForm.AuthorizeLoginSuperSmallForm.ConvertEnumToDescription(CustomAttributes.OperatingAuthority.UpdatePaymentTime).ToString()));
- }
- }
- }
- break;
- }
-
-
-
-
-
-
-
-
-
-
-
- }
-
-
-
-
-
- void btnSelect_Click(object sender, EventArgs e)
- {
- OpenFileDialog OpenFile = new OpenFileDialog();
- OpenFile.Filter = "图片文件(*.jpg)|*.jpg|图片文件(*.gif)|*.gif|图片文件(*.bmp)|*.bmp|图片文件(*.png)|*.png";
- OpenFile.FileName = "";
- if (OpenFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- this.labelEx6.ForeColor = Color.Red;
- this.pictPhoto.Tag = OpenFile.FileName;
- this.pictPhoto.Image = LYFZ.BLL.SelectPhotoHandling.GeneratePreviewBitmap(OpenFile.FileName, 600, 800);
- }
- }
- bool IsDeletePhoto = false;
-
-
-
-
-
- void btnDelete_Click(object sender, EventArgs e)
- {
- LYFZ.Model.Model_ErpOtherIncomeAndExpenses model = oiebll.GetModel(this.OutlayID);
- model.Oiae_Invoice = "";
- if (oiebll.Update(model))
- {
- this.IsDeletePhoto = true;
- this.pictPhoto.Image = null;
- this.pictPhoto.Tag = null;
- }
- }
-
-
-
-
-
- void pictPhoto_MouseDoubleClick(object sender, MouseEventArgs e)
- {
- if (this.OutlayID > 0)
- {
- LYFZ.Software.MainBusiness.FinancialManagement.SetSmallForm.PhotoZoomSetSmallForm frm = new PhotoZoomSetSmallForm();
- frm.PhotoImage = this.pictPhoto.Image;
- frm.ShowDialog();
- }
- }
-
-
-
-
-
- void txtOiae_Money_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
- { e.Handled = true; }
- else if (Char.IsPunctuation(e.KeyChar))
- {
- if (e.KeyChar == '.')
- {
- if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('.') != -1)
- { e.Handled = true; }
- }
- else if (e.KeyChar == '-')
- {
- if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('-') != -1)
- { e.Handled = true; }
- }
- else
- { e.Handled = true; }
- }
- }
- }
- }
|