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.添加: //this.panelPict.Visible = false; //this.Height -= this.panelPict.Height; 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 hideControl = new List(); 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_Invoice = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ToHexString(LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ImageDatabytes(this.pictPhoto)); 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; } //if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OrdersReceivablesCompetence, CustomAttributes.OperatingAuthority.UpdatePaymentTime)) //{ this.txtOiae_IEDatetime.Enabled = true; } //else //{ // LYFZ.Software.MainBusiness.DoorCityProcess.SuperSmallForm.AuthorizeLoginSuperSmallForm frm = new DoorCityProcess.SuperSmallForm.AuthorizeLoginSuperSmallForm(); // if (frm.ShowDialog() == DialogResult.OK) // { // if (LYFZ.BLL.BLL_ErpUser.GetRights(frm.CurrentAuthorizeUserRights.OrdersReceivablesCompetence, CustomAttributes.OperatingAuthority.UpdatePaymentTime, frm.User_BelongRoles)) // { this.txtOiae_IEDatetime.Enabled = true; } // } //} } /// /// 浏览 /// /// /// 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; } } } } }