private void InitComboBoxEdit() { for (int i = 0; i < GV_Main.RowCount; i++) { int idx = GV_Main.GetRowHandle(i); string mXB007 = "[" + GV_Main.GetRowCellValue(idx, "XB007").ToString() + "] " + GV_Main.GetRowCellValue(idx, "XB007C").ToString(); if (!cbo01.Properties.Items.Contains(mXB007)) { cbo01.Properties.Items.Add(mXB007); } } if (cbo01.Properties.Items.Count > 0) { cbo01.SelectedIndex = 0; } }
private void XK006ButtonEdit_ButtonClick(object sender, ButtonPressedEventArgs e) { //if (GetGridStatu() != BaseForm.GridStatu.gsBrowse) { int mRowHandle = GV_Main.FocusedRowHandle; string mType = GV_Main.GetFocusedRowCellValue("XK005").ToString(); f2.SetMI = new string[] { "POSXH", "002" }; //f2.SetMIParam = new string[] { GV_Main.GetFocusedRowCellValue("XK005").ToString(), FData[3], FData[4], FData[3], FData[4] }; //f2.SetMIParam = new string[] { FData[3], FData[4], FData[5], FData[4], FData[5] }; f2.SetMIParam = new string[] { mType, FData[3], FData[4], FData[5] }; f2.SetMuity = true; Dictionary <int, List <string> > muity = null; if (f2.GetMI) { muity = f2.GetMuity; bool IsExist = false; bool IsFirst = true; foreach (KeyValuePair <int, List <string> > s in muity) { for (int i = 0; i < GV_Main.RowCount; i++) { int idx = GV_Main.GetRowHandle(i); if ((GV_Main.GetRowCellValue(idx, "XK006") == null)) { IsExist = false; break; } if (GV_Main.GetRowCellValue(idx, "XK006").ToString() == s.Value[0]) { if (GV_Main.GetRowCellValue(idx, "XK005").ToString() == mType) { if (idx == mRowHandle) { IsFirst = false; } IsExist = true; break; } } } if (IsExist) { IsExist = false; continue; } else { if (IsFirst) { IsFirst = false; } else { GV_Main.AddNewRow(); } int mIndex = GV_Main.RowCount; GV_Main.SetFocusedRowCellValue("XK001", FData[0]); GV_Main.SetFocusedRowCellValue("XK002", FData[1]); GV_Main.SetFocusedRowCellValue("XK003", FData[2]); GV_Main.SetFocusedRowCellValue("XK004", string.Format("{0:0000}", mIndex)); GV_Main.SetFocusedRowCellValue("XK005", mType); GV_Main.SetFocusedRowCellValue("XK006", s.Value[0]); GV_Main.SetFocusedRowCellValue("XK006C", s.Value[1]); GV_Main.SetFocusedRowCellValue("XH004", s.Value[2]); GV_Main.UpdateCurrentRow(); } } } } }
private void btnOK_Click(object sender, EventArgs e) { string mNo = ""; string mSQL = ""; string mXR001 = ""; try { using (SqlConnection conn = new SqlConnection(fc.makeConnectString(fc.FDBInfo))) { conn.Open(); using (SqlCommand cmd = new SqlCommand("SELECT MAX(XR001) AS XR001 FROM POSXR ", conn)) { using (SqlDataReader dr = cmd.ExecuteReader()) { if (dr.Read()) { mXR001 = dr["XR001"].ToString(); } } } if (mXR001 != "") { mNo = "S" + DateTime.Now.ToString("yyyyMMdd") + fc.ZeroatFirst((Int32.Parse(mXR001.Substring(9, mXR001.Length - 9)) + 1), 4); } else { mNo = "S" + DateTime.Now.ToString("yyyyMMdd") + "0001"; } mSQL = "SELECT XR001 FROM POSXR WHERE XR001='" + mNo + "'"; for (int i = 0; i < GV_Main.RowCount; i++) { while (!ValidMaxNo(mSQL)) { mNo = mNo.Substring(0, 9) + fc.ZeroatFirst((Int32.Parse(mNo.Substring(9, mNo.Length - 9)) + 1), 4); mSQL = "SELECT XR001 FROM POSXR WHERE XR001='" + mNo + "'"; } int mHandle = GV_Main.GetRowHandle(i); float mXR005 = 0; float.TryParse(GV_Main.GetRowCellValue(mHandle, "XR005").ToString(), out mXR005); if (mXR005 == 0) { continue; } string mSQL2 = "INSERT INTO POSXR (XR001,XR002,XR003,XR004,XR005,XR006) VALUES(@XR001,@XR002,@XR003,@XR004,@XR005,@XR006)"; using (SqlCommand cmd = new SqlCommand(mSQL2, conn)) { cmd.Parameters.AddWithValue("@XR001", mNo); cmd.Parameters.AddWithValue("@XR002", GV_Main.GetRowCellValue(mHandle, "XF002").ToString()); cmd.Parameters.AddWithValue("@XR003", GV_Main.GetRowCellValue(mHandle, "XG002").ToString()); cmd.Parameters.AddWithValue("@XR004", fc.FUser.ID); cmd.Parameters.AddWithValue("@XR005", GV_Main.GetRowCellValue(mHandle, "XR005").ToString()); cmd.Parameters.AddWithValue("@XR006", GV_Main.GetRowCellValue(mHandle, "XR006").ToString()); cmd.ExecuteNonQuery(); } } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); fc.ErrorLog(ex.Message); } }