public override void BtnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (GetGridStatu() == GridStatu.gsAdd) { int mRow = 0; string mNo = XF001.Text; string mSQL = "SELECT XF001 FROM POSXC LEFT JOIN POSXF ON XC001=XF008 WHERE XF001='" + mNo + "'"; while (!ValidMaxNo(mSQL)) { mNo = mNo.Substring(0, 9) + fc.ZeroatFirst((Int32.Parse(mNo.Substring(9, mNo.Length - 9)) + 1), 2); mSQL = "SELECT XF001 FROM POSXC LEFT JOIN POSXF ON XC001=XF008 WHERE XF001='" + mNo + "'"; } XF001.Text = mNo; //單身 for (int i = 0; i < GV_Body.RowCount; i++) { mRow = GV_Body.GetRowHandle(i); GV_Body.SetRowCellValue(mRow, "XG001", XF001.Text); //口味加料子單身 GV_Body.SetMasterRowExpanded(mRow, true); GridView gridViewTests = GV_Body.GetDetailView(mRow, 0) as GridView; if (gridViewTests != null) { for (int j = 0; j < gridViewTests.Columns.Count; j++) { gridViewTests.SetRowCellValue(mRow, "XK001", XF001.Text); } } } } base.BtnSave_ItemClick(sender, e); }
private void XG009ButtonEdit_ButtonClick(object sender, ButtonPressedEventArgs e) { if (GetGridStatu() != BaseForm.GridStatu.gsBrowse) { try { GV_Body.UpdateCurrentRow(); f2.SetMI = new string[] { "POSXN", "001" }; f2.SetMIParam = new string[] { XF002.Text, "1", GV_Body.GetFocusedRowCellValue("XB007").ToString(), "2", GV_Body.GetFocusedRowCellValue("XG002").ToString() }; f2.SetShowWindow = false; if (f2.GetMI) { string mXN002 = f2.GetReturn[2]; string mXN003 = f2.GetReturn[3]; double money = 0; double mXB004 = 0; double mQty = 0; string MarkInfo = ""; RESAI04I ai04i = new RESAI04I(); string mXG001 = GV_Body.GetFocusedRowCellValue("XG001").ToString(); string mXG010 = GV_Body.GetFocusedRowCellValue("XG010").ToString(); string mXG002 = GV_Body.GetFocusedRowCellValue("XG002").ToString(); ai04i.DefaultData = new List <string>() { mXG001, mXG010, mXG002, XF002.Text, mXN002, mXN003 }; DataTable dtPOSXK = new DataTable("POSXK"); GridView gridViewTests = null; float mXH004 = 0; for (int i = 0; i < dS_RESAI04.POSXK.Columns.Count; i++) { dtPOSXK.Columns.Add(dS_RESAI04.POSXK.Columns[i].ColumnName, dS_RESAI04.POSXK.Columns[i].DataType); } //if (!GV_Body.IsMasterRowEmpty(GV_Body.FocusedRowHandle)) { GV_Body.SetMasterRowExpanded(GV_Body.FocusedRowHandle, true); gridViewTests = GV_Body.GetDetailView(GV_Body.FocusedRowHandle, 0) as GridView; if (gridViewTests != null) { for (int i = 0; i < gridViewTests.RowCount; i++) { int idx = gridViewTests.GetRowHandle(i); float.TryParse(gridViewTests.GetRowCellValue(idx, "XH004").ToString(), out mXH004); dtPOSXK.Rows.Add(new object[] { "", "", "", "", "", "", 0, "", "", "", "", //}); gridViewTests.GetRowCellValue(idx, "XK001").ToString(), gridViewTests.GetRowCellValue(idx, "XK002").ToString(), gridViewTests.GetRowCellValue(idx, "XK003").ToString(), gridViewTests.GetRowCellValue(idx, "XK004").ToString(), gridViewTests.GetRowCellValue(idx, "XK005").ToString(), gridViewTests.GetRowCellValue(idx, "XK006").ToString(), gridViewTests.GetRowCellValue(idx, "XK006C").ToString(), mXH004 }); } } } ai04i.SetPOSXK = dtPOSXK; if (ai04i.ShowDialog() == DialogResult.OK) { dtPOSXK = ai04i.SetPOSXK; while (gridViewTests.RowCount != 0) { gridViewTests.SelectAll(); gridViewTests.DeleteSelectedRows(); } for (int i = 0; i < dtPOSXK.Rows.Count; i++) { gridViewTests.BeginUpdate(); gridViewTests.AddNewRow(); gridViewTests.SetFocusedRowCellValue("COMPANY", dtPOSXK.Rows[i]["COMPANY"]); gridViewTests.SetFocusedRowCellValue("CREATOR", dtPOSXK.Rows[i]["CREATOR"]); gridViewTests.SetFocusedRowCellValue("USR_GROUP", dtPOSXK.Rows[i]["USR_GROUP"]); gridViewTests.SetFocusedRowCellValue("CREATE_DATE", dtPOSXK.Rows[i]["CREATE_DATE"]); gridViewTests.SetFocusedRowCellValue("MODIFIER", dtPOSXK.Rows[i]["MODIFIER"]); gridViewTests.SetFocusedRowCellValue("MODI_DATE", dtPOSXK.Rows[i]["MODI_DATE"]); gridViewTests.SetFocusedRowCellValue("FLAG", dtPOSXK.Rows[i]["FLAG"]); gridViewTests.SetFocusedRowCellValue("CREATE_TIME", dtPOSXK.Rows[i]["CREATE_TIME"]); gridViewTests.SetFocusedRowCellValue("MODI_TIME", dtPOSXK.Rows[i]["MODI_TIME"]); gridViewTests.SetFocusedRowCellValue("TRANS_TYPE", dtPOSXK.Rows[i]["TRANS_TYPE"]); gridViewTests.SetFocusedRowCellValue("TRANS_NAME", dtPOSXK.Rows[i]["TRANS_NAME"]); gridViewTests.SetFocusedRowCellValue("XK001", dtPOSXK.Rows[i]["XK001"]); gridViewTests.SetFocusedRowCellValue("XK002", dtPOSXK.Rows[i]["XK002"]); gridViewTests.SetFocusedRowCellValue("XK003", dtPOSXK.Rows[i]["XK003"]); gridViewTests.SetFocusedRowCellValue("XK004", dtPOSXK.Rows[i]["XK004"]); gridViewTests.SetFocusedRowCellValue("XK005", dtPOSXK.Rows[i]["XK005"]); gridViewTests.SetFocusedRowCellValue("XK006", dtPOSXK.Rows[i]["XK006"]); gridViewTests.SetFocusedRowCellValue("XK006C", dtPOSXK.Rows[i]["XK006C"]); gridViewTests.SetFocusedRowCellValue("XH004", dtPOSXK.Rows[i]["XH004"]); money += float.Parse(dtPOSXK.Rows[i]["XH004"].ToString()); MarkInfo += dtPOSXK.Rows[i]["XK006C"].ToString() + ","; gridViewTests.EndUpdate(); gridViewTests.UpdateCurrentRow(); } mXB004 = float.Parse(GV_Body.GetFocusedRowCellValue("XB004").ToString()); mQty = float.Parse(GV_Body.GetFocusedRowCellValue("XG003").ToString());; money += mXB004; GV_Body.SetFocusedRowCellValue("XG004", money * mQty); GV_Body.SetFocusedRowCellValue("XG009", MarkInfo); GV_Body.UpdateCurrentRow(); } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); fc.ErrorLog(ex.Message); } } }