public static string[] WriteCons(CONNViewModel _cons) { string[] _co = new string[22]; _co[0] = _cons.txt1; _co[1] = _cons.txt2; _co[2] = _cons.txt3; _co[3] = _cons.txt4; _co[4] = _cons.txt5; _co[5] = _cons.txt6; _co[6] = _cons.txt7; _co[7] = _cons.txt9; _co[8] = _cons.txt8; _co[9] = _cons.txt10; _co[10] = _cons.txt11; _co[11] = _cons.txt12; _co[12] = _cons.txt13; _co[13] = _cons.txt14; _co[14] = _cons.txt15; _co[15] = _cons.txt16; _co[16] = _cons.txt17; _co[17] = _cons.txt18; _co[18] = _cons.txt19; _co[19] = _cons.txt20; _co[20] = _cons.txt21; _co[21] = _cons.txt22; return(_co.AddQutation()); }
public static bool Insert(CONNViewModel _con) { try { using (IDbConnection db = new SQLiteConnection(DataAccess.GetConnectionString())) { string query = "INSERT INTO CON " + "(CTRRef, CTRNo ,BolRef, BolNo, txt1, txt2, txt3, txt4, txt5, txt6, txt7, txt8, txt9, txt10, txt11, txt12, txt13, txt14, txt15, txt16, txt17, txt18, txt19, txt20, txt21, txt22)" + "VALUES(@CTRRef, @CTRNo, @BolRef, @BolNo, @txt1, @txt2, @txt3, @txt4, @txt5, @txt6, @txt7, @txt8, @txt9, @txt10, @txt11, @txt12, @txt13, @txt14, @txt15, @txt16, @txt17, @txt18, @txt19, @txt20, @txt21, @txt22)"; db.Execute(query, _con); } return(true); } catch (Exception ex) { Console.WriteLine(ex.Message); return(false); throw; } }
public static bool Update(CONNViewModel _con) { try { using (IDbConnection db = new SQLiteConnection(DataAccess.GetConnectionString())) { string query = "UPDATE CON " + "SET BolRef=@BolRef, BolNo=@BolNo, txt1 =@txt1, txt2 =@txt2, txt3 =@txt3, txt4 =@txt4, txt5 =@txt5, txt6 =@txt6, txt7 =@txt7, txt8 =@txt8, " + "txt9 =@txt9, txt10 =@txt10, txt11 =@txt11, txt12 =@txt12, txt13 =@txt13, txt14 =@txt14, txt15 =@txt15, txt16 =@txt16," + "txt17 =@txt17, txt18 =@txt18, txt19 =@txt19, txt20 =@txt20, txt21 =@txt21, txt22 =@txt22 Where ID=@ID"; db.Execute(query, _con); } return(true); } catch (Exception ex) { Console.WriteLine(ex.Message); return(false); throw; } }
private void btnSaveKala_Click(object sender, EventArgs e) { try { CONNViewModel cons = new CONNViewModel { CTRRef = int.Parse(cmbContainerNumber.SelectedValue.ToString()), CTRNo = cmbContainerNumber.Text, //BolRef = int.Parse(cmbBlNo.SelectedValue.ToString()), //BolNo = cmbBlNo.Text, txt1 = "CON", txt2 = txt01.Text, txt3 = txt02.Text, txt4 = txt03.Text, txt6 = txt05.Text, txt7 = txt06.Text, txt8 = cmb08.Text, txt9 = cmb07.Text, txt10 = txt09.Text, txt11 = txt10.Text, txt12 = txt11.Text, txt13 = cmb12.Text, txt19 = cmb18.Text, }; if (KalaEditID == 0)//Save { CONN.Insert(cons); } else //Edit { cons.ID = int.Parse(dgvKala.CurrentRow.Cells["KALA_ID"].Value.ToString()); CONN.Update(cons); cmbContainerNumber.Enabled = true; btnSaveKala.Text = "ذخیره کالا"; } //Empty All Textboxes foreach (Control c1 in tabRequired.Controls) { if (c1 is TextBox) { c1.Text = string.Empty; } } SetTabPage2Defaults(); progressBar3.Value = 75; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { //Refresh dgv dgvKala.DataSource = null; dgvKala.DataSource = CONN.GetAllData(); KalaEditID = 0; btnSaveKala.Text = "دخیره کالا"; } }
private void btnSave_Click(object sender, EventArgs e) { if (!IsAllRequiredTextFilled() || (cmb08.Text.Trim() == string.Empty)) { MessageBox.Show("لطفا همه فیلدها را پر کنید"); ActiveControl = cmbBlNo; return; } try { //Save or Edit Ctr CTRViewModel ctr = new CTRViewModel { ID = 1, txt1 = "CTR", BolRef = int.Parse(cmbBlNo.SelectedValue.ToString()), txt2 = chkFake.Checked ? "FAKE123456-1" : txtCtr1.Text, txt3 = txtCtr2.Text, txt4 = lblCtr3.Text, txt5 = txtCtr4.Text }; if (CTR.IsFirstRecord()) //Save { CTR.Insert(ctr); } else //Update { CTR.Update(ctr); } //============================= Save or Edit Cons ================================= CONNViewModel cons = new CONNViewModel { CTRRef = 1, BolRef = int.Parse(cmbBlNo.SelectedValue.ToString()), BolNo = cmbBlNo.Text, txt1 = "CON", txt2 = txt01.Text, txt3 = txt02.Text, txt4 = txt03.Text, txt6 = txt05.Text, txt7 = txt06.Text, txt8 = cmb08.Text, txt9 = cmb07.Text, txt10 = txt09.Text, txt11 = txt10.Text, txt12 = txt11.Text, txt13 = cmb12.Text, txt19 = cmb18.Text, }; if (EditID == 0)//Save { CONN.Insert(cons); } else //Edit { cons.ID = int.Parse(dgv.CurrentRow.Cells["ID"].Value.ToString()); CONN.Update(cons); } //Empty All Textboxes foreach (Control c2 in TabPage1.Controls) { if (c2 is TextBox) { c2.Text = string.Empty; } } //Refresh dgv dgv.DataSource = null; dgv.DataSource = CONN.GetAllDataSortedByBolNo(); EditID = 0; btnSave.Text = "دخیره کالا"; } catch (Exception ex) { MessageBox.Show(ex.Message); } }