private void menuStripItem_Click(object sender, MouseEventArgs e) { if (this.MasterGrid != null) { MyGrid.CancelEditCurrentDataRow(this.MasterGrid); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected override void DisplayManager_PositionChanged(object sender, EventArgs e) { if (IsClosed) { return; } //if (this.DisplayManager.InBatchOperation) //{ // return; //} base.DisplayManager_PositionChanged(sender, e); if (this.DisplayManager.Position == -1) { foreach (IBoundGrid grid in m_detailGrids) { MyGrid.CancelEditCurrentDataRow(grid); grid.DataRows.Clear(); } } else { ReloadDetailGridData(); } }
void DisplayManager_PositionChanged(object sender, EventArgs e) { if (m_cm.DisplayManager.Position == -1) { MyGrid.CancelEditCurrentDataRow(m_显示区Grid); m_显示区Grid.DataRows.Clear(); } else { m_显示区Grid.ReloadData(false); } var entity = m_cm.DisplayManagerT.CurrentEntity; if (entity == null) { return; } if (entity.IsActive) { btn删除.Enabled = false; btn修改.Enabled = false; } else { btn删除.Enabled = true; btn修改.Enabled = true; } }
internal static void OnButtonClick(WindowMenuInfo windowMenuInfo, System.Windows.Forms.Form parentForm) { IArchiveDetailFormWithDetailGrids addg = parentForm as IArchiveDetailFormWithDetailGrids; if (addg != null) { foreach (IBoundGrid i in addg.DetailGrids) { MyGrid.CancelEditCurrentDataRow(i); } } IGridContainer agf = parentForm as IGridContainer; if (agf != null) { MyGrid.CancelEditCurrentDataRow(agf.MasterGrid); } IControlManagerContainer cmc = parentForm as IControlManagerContainer; if (cmc != null) { InternalExecuteWindowMenu(cmc.ControlManager, windowMenuInfo, parentForm); } else { IDisplayManagerContainer dmc = parentForm as IDisplayManagerContainer; if (dmc != null) { InternalExecuteWindowMenu(dmc.DisplayManager, windowMenuInfo, parentForm); //InternalExecuteWindowMenu((parentForm as ArchiveDetailForm).ParentArchiveForm, windowMenuInfo); } } }
protected virtual void DisplayManager_PositionChanged(object sender, EventArgs e) { if (this.DisplayManager.InBatchOperation) { return; } try { this.DisplayManager.BeginBatchOperation(); if (this.DisplayManager.Position == -1 || this.DisplayManager.Position >= this.DataRows.Count) { // do nothing for not change currentRow //this.CurrentRow = null; } else { // grid处于编辑状态时,Position改变,而且先不EndEdit,则要Cancel否则可能ValidationFail MyGrid.CancelEditCurrentDataRow(this); MyGrid.SetCurrentRow(this, this.DataRows[this.DisplayManager.Position]); } } finally { this.DisplayManager.EndBatchOperation(); } }
void cm_EditCanceled(object sender, EventArgs e) { foreach (IBoundGrid grid in m_detailGrids) { MyGrid.CancelEditCurrentDataRow(grid); } foreach (IBoundGrid grid in m_detailGrids) { grid.ReloadData(false); } }
void DisplayManager_PositionChanged(object sender, EventArgs e) { if (m_cm.DisplayManager.Position == -1) { MyGrid.CancelEditCurrentDataRow(m_显示区Grid); m_显示区Grid.DataRows.Clear(); } else { m_显示区Grid.ReloadData(false); } var entity = m_cm.DisplayManagerT.CurrentEntity; if (entity == null) { return; } bool ret = true; if (entity.任务 != null) { foreach (var i in entity.任务) { if (!string.IsNullOrEmpty(i.任务号) || i.是否拒绝) { ret = false; } } } else { ret = false; } btn修改.Enabled = ret; btn拒绝.Enabled = ret; btn备案确认.Enabled = ret; }
void 用途分类_SelectedDataValueChanged(object sender, EventArgs e) { 业务分类.ReadOnly = false; 业务分类.SelectedDataValue = null; grdFymx.DataRows.Clear(); grdFymx.VisibleColumns(false); MyGrid.CancelEditCurrentDataRow(grdFymx); if (用途分类.SelectedDataValue == null) { return; } IDisplayManager dm = sender as IDisplayManager; int ytfl = (int)用途分类.SelectedDataValue; string[] neededColumns = null; if (ytfl == 101) // 业务应收 { neededColumns = new string[] { "费用项", "金额", "备注" }; } else if (ytfl == 103) //其他应付 { // "费用项" = "002" neededColumns = new string[] { "金额", "备注" }; } else if (ytfl == 203 || ytfl == 204 || ytfl == 205) // 借款套现押金 { // "费用项" = "012" neededColumns = new string[] { "金额", "备注" }; } else { neededColumns = new string[] { "费用项", "金额", "备注" }; } foreach (Xceed.Grid.Column column in grdFymx.Columns) { if (Array.IndexOf <string>(neededColumns, column.FieldName) != -1) { column.Visible = true; column.ReadOnly = false; } else { column.Visible = false; column.ReadOnly = true; } } grdFymx.AutoAdjustColumnWidth(); NameValueMappingCollection.Instance["信息_凭证业务类型_动态"].Params["@收付标志"] = Hd.Model.收付标志.收; NameValueMappingCollection.Instance["信息_凭证业务类型_动态"].Params["@凭证费用类别"] = ytfl; NameValueMappingCollection.Instance.Reload(dm.Name, "信息_凭证业务类型_动态"); //(业务分类.Control as MyComboBox).RefreshData(); if (!业务分类.ReadOnly) { DataView dv = NameValueMappingCollection.Instance.GetDataSource(dm.Name, "信息_凭证业务类型_动态"); if (dv.Count == 0) { 业务分类.ReadOnly = true; } else { 业务分类.ReadOnly = false; if (dv.Count == 0) { 业务分类.SelectedDataValue = dv[0][NameValueMappingCollection.Instance["信息_凭证业务类型_动态"].ValueMember]; } } //(业务分类.Control as MyComboBox).SetDataBinding( // DbHelper.Instance.ExecuteDataTable("SELECT 代码, 类型 FROM 信息_凭证业务分类 WHERE 付 = 'true' AND 支出类别 = '" + ytfl + "'"), string.Empty); } else { 业务分类.SelectedDataValue = null; } if (!grdFymx.Columns["费用项"].ReadOnly) { //if (ytfl != "999") { NameValueMappingCollection.Instance["信息_凭证费用项_动态"].Params["@收付标志"] = Hd.Model.收付标志.收; NameValueMappingCollection.Instance["信息_凭证费用项_动态"].Params["@凭证费用类别"] = ytfl; NameValueMappingCollection.Instance.Reload(dm.Name, "信息_凭证费用项_动态"); } //else //{ //} //(grdFymx.Columns["费用项"].CellEditorManager as Feng.Grid.Editors.MyComboBoxEditor).SetDataBinding( // DbHelper.Instance.ExecuteDataTable("SELECT 编号, 名称 FROM 信息_凭证费用项 WHERE 付 = 'true' AND 凭证支出类别 = '" + ytfl + "'"), string.Empty); } 用途分类.ReadOnly = true; grdFymx.ReadOnly = false; }
void 用途分类_SelectedDataValueChanged(object sender, EventArgs e) { //业务分类.ReadOnly = false; label10.Text = "业务分类"; 业务分类.Control.Text = string.Empty; MyGrid.CancelEditCurrentDataRow(grdFymx); grdFymx.DataRows.Clear(); grdFymx.VisibleColumns(false); if (用途分类.SelectedDataValue == null) { return; } 凭证用途分类 ytfl = (凭证用途分类)用途分类.SelectedDataValue; int?pzfylb = null; string[] neededColumns = null; if (ytfl == 凭证用途分类.业务应付) { pzfylb = 102; // 业务应付 neededColumns = new string[] { "费用项", "金额", "支付方式要求", "备注" }; } else if (ytfl == 凭证用途分类.业务报销) // 业务报销 { pzfylb = 102; neededColumns = new string[] { "费用项", "金额", "自编号", "箱号" }; } else if (ytfl == 凭证用途分类.其他应付) //其他应付 { // "费用项" = "002" neededColumns = new string[] { "金额", "支付方式要求", "备注" }; } //else if (ytfl == 凭证用途分类.代收代付) // 借款套现押金 //{ // // "费用项" = "012" // // no pzfylb; // neededColumns = new string[] { "凭证费用类别", "业务分类", "金额", "结算期限", "支付方式要求", "备注" }; //} else if (ytfl == 凭证用途分类.其他报销) { // no pzfylb; neededColumns = new string[] { "凭证费用类别", "费用项", "金额", "支付方式要求", "备注" }; } foreach (Xceed.Grid.Column column in grdFymx.Columns) { if (Array.IndexOf <string>(neededColumns, column.FieldName) != -1) { column.Visible = true; column.ReadOnly = false; } else { column.Visible = false; column.ReadOnly = true; } } grdFymx.AutoAdjustColumnWidth(); if (pzfylb.HasValue) { //// only for 报销 //NameValueMappingCollection.Instance["信息_凭证业务类型_动态"].Params["@收付标志"] = Hd.Model.收付标志.付; //NameValueMappingCollection.Instance["信息_凭证业务类型_动态"].Params["@凭证费用类别"] = pzfylb; //NameValueMappingCollection.Instance.Reload("信息_凭证业务类型_动态"); //(业务分类.Control as MyComboBox).RefreshData(); label10.Text = "业务分类"; (业务分类.Control as MyComboBox).ValidateText = true; 业务分类.ReadOnly = false; 用途分类.Focus(); } else { label10.Text = "部门"; (业务分类.Control as MyComboBox).TextBoxArea.Text = "进口部"; (业务分类.Control as MyComboBox).ValidateText = false; 业务分类.ReadOnly = true; 用途分类.Focus(); } //if (!业务分类.ReadOnly) //{ // DataTable dt = NameValueMappingCollection.Instance.DataTable("信息_凭证业务类型_动态"); // if (dt.Rows.Count == 0) // { // 业务分类.ReadOnly = true; // } // else // { // 业务分类.ReadOnly = false; // if (dt.Rows.Count == 0) // { // 业务分类.SelectedDataValue = dt.Rows[0][NameValueMappingCollection.Instance["信息_凭证业务类型_动态"].ValueMember]; // } // } // //(业务分类.Control as MyComboBox).SetDataBinding( // // DbHelper.Instance.ExecuteDataTable("SELECT 代码, 类型 FROM 信息_凭证业务分类 WHERE 付 = 'true' AND 支出类别 = '" + ytfl + "'"), string.Empty); //} //else //{ // 业务分类.SelectedDataValue = null; //} //if (!grdFymx.Columns["凭证费用类别"].ReadOnly) //{ // //if (ytfl != "999") // { // NameValueMappingCollection.Instance["信息_凭证费用类别_动态"].Params["@收付标志"] = Hd.Model.收付标志.付; // NameValueMappingCollection.Instance.Reload("信息_凭证费用类别_动态"); // NameValueMappingCollection.Instance["信息_凭证费用项_动态"].Params["@收付标志"] = Hd.Model.收付标志.付; // NameValueMappingCollection.Instance["信息_凭证费用项_动态"].Params["@凭证费用类别"] = ytfl; // NameValueMappingCollection.Instance.Reload("信息_凭证费用项_动态"); // } // //else // //{ // //} // //(grdFymx.Columns["费用项"].CellEditorManager as Feng.Grid.Editors.MyComboBoxEditor).SetDataBinding( // // DbHelper.Instance.ExecuteDataTable("SELECT 编号, 名称 FROM 信息_凭证费用项 WHERE 付 = 'true' AND 凭证支出类别 = '" + ytfl + "'"), string.Empty); //} 用途分类.ReadOnly = true; grdFymx.ReadOnly = false; SetTopGrid(); }
private void tsbSave_Click(object sender, EventArgs e) { if (m_haveSaved) { if (!ServiceProvider.GetService <IMessageBox>().ShowYesNoDefaultNo("已保存过一次,是否再次保存(会导致2份记录)?", "确认")) { return; } } int cnt = 0; IBatchDao batchDao = m_cm.Dao as IBatchDao; if (batchDao == null) { ServiceProvider.GetService <IMessageBox>().ShowWarning("不支持批量保存,将逐条保存!"); } try { m_cm.CancelEdit(); MyGrid.CancelEditCurrentDataRow(m_excelGrid); if (batchDao != null) { batchDao.SuspendOperation(); } foreach (Xceed.Grid.DataRow row in m_excelGrid.DataRows) { bool hasValue = false; foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(m_excelGrid.GridName)) { if (row.Cells[info.GridColumnName] != null && !string.IsNullOrEmpty(info.PropertyName)) { if (row.Cells[info.GridColumnName].ReadOnly) { continue; } if (row.Cells[info.GridColumnName].Value != null) { hasValue = true; } } } if (!hasValue) { continue; } object entity = m_cm.AddNew(); if (entity == null) { continue; } foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(m_excelGrid.GridName)) { if (row.Cells[info.GridColumnName] != null && !string.IsNullOrEmpty(info.PropertyName)) { if (row.Cells[info.GridColumnName].ReadOnly) { continue; } EntityScript.SetPropertyValue(entity, info.Navigator, info.PropertyName, row.Cells[info.GridColumnName].Value); } } m_cm.EndEdit(false); m_cm.Dao.Save(entity); cnt++; } if (batchDao != null) { batchDao.ResumeOperation(); } m_haveSaved = true; MessageForm.ShowInfo(string.Format("已保存{0}条记录!", cnt)); } catch (Exception ex) { if (batchDao != null) { batchDao.CancelSuspendOperation(); } ExceptionProcess.ProcessWithNotify(ex); } }