private void UpdateTableNDC() { string query = @"UPDATE tblndc SET DispDate='" + dtDD.Text + "',Waybill='" + txtWaybill.Text + "',BodyNum='" + txtBodyNum.Text + "',PlateNum='" + txtPlateNum.Text + "',Driver='" + txtDriver.Text + "',Helper='" + txtHelper.Text + "',Source='" + txtSource.Text + "',RDD='" + dtRDD.Text + "',CommitTime='" + dtComTime.Text + "',Cases='" + txtCase.Text + "',TruckReq='" + txtTruckReq.Text + "',CustName='" + txtCustName.Text + "',TruckIn='" + dtTruckIn.Text + "',Checklist='" + dtChecklist.Text + "',SCheck='" + dtSCheck.Text + "',FCheck='" + dtFCheck.Text + "',SLoad='" + dtSLoad.Text + "',FLoad='" + dtFLoad.Text + "',DocRec='" + dtDocRec.Text + "',INVCDN='" + txtINV.Text + "',TruckOut='" + dtTruckOut.Text + "',SDwell='" + txtDwell.Text + "',LoadNum='" + txtLN.Text + "' WHERE TripNum='" + int.Parse(lblTrip.Text) + "'"; DatabaseLibrary Obj = new DatabaseLibrary(); Obj.Connection(); try { Obj.Edit(query); frm1.RefreshRDD(); MessageBox.Show("Edit Success!", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); Obj.CloseConnection(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnSave_Click(object sender, EventArgs e) { int tnum; CountFile(); tnum = Convert.ToInt32(nCount); DatabaseLibrary Obj = new DatabaseLibrary(); if (listView1.Items.Count == 0) { MessageBox.Show("Please Add Details!"); } else if (listView1.Items.Count != 0) { DialogResult dr = MessageBox.Show(this, "Do you want to Save?", "Confimation", MessageBoxButtons.YesNo, MessageBoxIcon.Stop); if (dr == DialogResult.Yes) { try { for (int i = 0; i < listView1.Items.Count; i++) { tnum++; Obj.Connection(); Obj.Insert(@"INSERT INTO tblndc(TripNum,DispDate,Waybill,BodyNum,PlateNum,Driver,Helper,Source,RDD,CommitTime,Cases,TruckReq,CustName,TruckIn,Checklist,SCheck,FCheck,SLoad,FLoad,DocRec,INVCDN,TruckOut,SDwell,LoadNum) VALUES ('" + tnum + "','" + listView1.Items[i].SubItems[0].Text + "','" + listView1.Items[i].SubItems[1].Text + "','" + listView1.Items[i].SubItems[2].Text + "','" + listView1.Items[i].SubItems[3].Text + "','" + listView1.Items[i].SubItems[4].Text + "','" + listView1.Items[i].SubItems[5].Text + "','" + listView1.Items[i].SubItems[6].Text + "','" + listView1.Items[i].SubItems[7].Text + "','" + listView1.Items[i].SubItems[8].Text + "','" + listView1.Items[i].SubItems[9].Text + "','" + listView1.Items[i].SubItems[10].Text + "','" + listView1.Items[i].SubItems[11].Text + "','" + listView1.Items[i].SubItems[12].Text + "','" + listView1.Items[i].SubItems[13].Text + "','" + listView1.Items[i].SubItems[14].Text + "','" + listView1.Items[i].SubItems[15].Text + "','" + listView1.Items[i].SubItems[16].Text + "','" + listView1.Items[i].SubItems[17].Text + "','" + listView1.Items[i].SubItems[18].Text + "','" + listView1.Items[i].SubItems[19].Text + "','" + listView1.Items[i].SubItems[20].Text + "','" + listView1.Items[i].SubItems[21].Text + "','" + listView1.Items[i].SubItems[22].Text + "')"); Obj.CloseConnection(); } frm1.RefreshRDD(); this.Close(); MessageBox.Show("Data Saved!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { } } }