#region using System; using System.Data; using System.Drawing.Imaging; using CSFrameworkV5.Business; using CSFrameworkV5.Common; using CSFrameworkV5.Core; using CSFrameworkV5.Library; using CSFrameworkV5.Library.CommonClass; #endregion namespace CSFrameworkV5.SystemModule { /// /// 公司资料设置 /// public partial class frmCompanyInfo : frmBaseDataDictionary { public frmCompanyInfo() { InitializeComponent(); } private void BindingSummaryEditor(DataTable summary) { DoBindingEditorPanel(gcDetailEditor, summary); } protected override void ButtonStateChanged(UpdateType currentState) { var accessable = currentState == UpdateType.Add || currentState == UpdateType.Modify; base.SetDetailEditorsAccessable(gcDetailEditor, accessable); base.ButtonStateChanged(currentState); //禁用数据操作按钮 _buttons.GetButtonByName("btnView").Enable = false; _buttons.GetButtonByName("btnAdd").Enable = false; _buttons.GetButtonByName("btnDelete").Enable = false; _buttons.GetButtonByName("btnPrint").Enable = false; _buttons.GetButtonByName("btnPreview").Enable = false; _buttons.GetButtonByName("btnRefreshDataDict").Enable = false; } public override void DoCancel(IButtonInfo sender) { if (!Msg.AskQuestion("要取消修改吗?")) return; _BLL.GetSummaryData(true); //获取数据 BindingSummaryEditor(_BLL.SummaryTable); //绑定输入控件 _UpdateType = UpdateType.None; SetViewMode(); ButtonStateChanged(_UpdateType); } public override void DoEdit(IButtonInfo sender) { _UpdateType = UpdateType.Modify; SetEditMode(); ButtonStateChanged(_UpdateType); } public override void DoSave(IButtonInfo sender) { UpdateLastControl(); if (txtCompanyCode.Text == "") { Msg.Warning("公司编号不能为空!"); txtCompanyCode.Focus(); return; } if (txtNativeName.Text == "") { Msg.Warning("公司中文名称不能为空!"); txtNativeName.Focus(); return; } if (txtLogo.Image != null && txtLogo.Image.Width > 250) { var img = CImageLibrary.ResizeImage(txtLogo.Image, 250, 110); txtLogo.Image = img; var bs = CImageLibrary.GetImageBytes(img, ImageFormat.Png); //PNG格式清晰 SetEditorBindingValue(txtLogo, bs, true); } if (_BLL.Update()) { _UpdateType = UpdateType.None; SetViewMode(); ButtonStateChanged(_UpdateType); Msg.ShowInformation("保存成功!"); } else { Msg.ShowInformation("保存失败!"); } } private void frmCompanyInfo_Load(object sender, EventArgs e) { _BLL = new bllCompanyInfo(); //业务逻辑层 _BLL.GetSummaryData(true); //获取数据 _DetailGroupControl = gcDetailEditor; _SummaryView = new DevGridView(gvSummary); InitializeForm(); BindingSummaryEditor(_BLL.SummaryTable); //绑定输入控件 ButtonStateChanged(UpdateType.None); ShowDetailPage(true); tpSummary.Hide(); } public override void SetParameter(object param) { //if (param != null) // Msg.ShowInformation(param.ToStringEx()); } } }