private void BtnDelete_Click(object sender, EventArgs e) { string ProjectID = TxtProjectID.Text; string ProjectName = TxtAddProjecName.Text; string Ward = TxtAddWard.Text; string Location = TxtAddLocation.Text; if (TxtProjectID.Text == "") { TxtAddLog.Text = "Enter Project ID to Delete"; } else { DialogResult dr = MessageBox.Show("Are You Sure, you want to delete?", "Delete", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { //delete SQLiteConnection ConnectDb = new SQLiteConnection("Data Source = ProgramRecord.sqlite3"); ConnectDb.Open(); //string query = "DELETE FROM SWAT_Iterations WHERE ID ='" + TxtUpdateID.Text + "' "; string query = "DELETE FROM TableProjectRecords WHERE ProjectID ='" + TxtProjectID.Text + "' "; SQLiteCommand Cmd = new SQLiteCommand(query, ConnectDb); Cmd.ExecuteNonQuery(); ConnectDb.Close(); TxtProjectID.Text = ""; TxtAddLog.AppendText("Deleted Projedt ID: " + ProjectID + " => " + ProjectName + " of " + Ward + " at " + Location); TxtAddLog.AppendText(Environment.NewLine); using (System.IO.StreamWriter sw = System.IO.File.AppendText(@".\Log\Log.txt")) { Text2Write = "[" + DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm:ss") + "]" + " ---> " + "DELETE" + " ---> " + "Project ID: " + ProjectID + " " + ProjectName + " of " + Ward + " at " + Location; sw.WriteLine(Text2Write); } /*LblCheck.Text = "Log: "; * LblCheck.ForeColor = Color.Black; * LblCheckEvalFacto.Text = "Log: "; * LblCheckEvalFacto.ForeColor = Color.Black; * lblcheckRunningRatio.Text = "Log: "; * lblcheckRunningRatio.ForeColor = Color.Black;*/ Initial_State_of_Lablel(); } else if (dr == DialogResult.No) { //Nothing to do } } }
private void BtnDisplay_Click(object sender, EventArgs e) { if (TxtProjectID.Text == "") { TxtAddLog.AppendText("Enter Project ID to Display"); TxtAddLog.AppendText(Environment.NewLine); } else { SQLiteConnection ConnectDb = new SQLiteConnection("Data Source = ProgramRecord.sqlite3"); ConnectDb.Open(); //string query = "SELECT * FROM SWAT_Iterations where ID = '" + TxtUpdateID.Text + "'"; string query = "SELECT * FROM TableProjectRecords where ProjectID = '" + TxtProjectID.Text + "'"; SQLiteDataAdapter DataAdptr = new SQLiteDataAdapter(query, ConnectDb); DataTable Dt = new DataTable(); DataAdptr.Fill(Dt); //string value; foreach (DataRow row in Dt.Rows) //there is only one row here { //value = row[1].ToString(); //TxtAddProjecName.Text = row[1].ToString(); TxtAddFiscalYear.Text = row[1].ToString(); TxtAddProjecName.Text = row[2].ToString(); TxtAddWard.Text = row[3].ToString(); TxtAddLocation.Text = row[4].ToString(); TxtAddBudgetType.Text = row[5].ToString(); TxtWorkPermit.Text = row[6].ToString(); TxtWorkStart.Text = row[7].ToString(); TxtFirstRunBill.Text = row[8].ToString(); TxtFinalBill.Text = row[9].ToString(); TxtAddCurStatus.Text = row[10].ToString(); TxtDescription.Text = row[11].ToString(); TxtAddRemark.Text = row[12].ToString(); TxtLabReport.Text = row[13].ToString(); TxtBoard.Text = row[14].ToString(); TxtAddProgramBudget.Text = row[15].ToString(); TxtAddContingency.Text = row[16].ToString(); TxtAddEstiBud0.Text = row[17].ToString(); TxtAddNetPay0.Text = row[18].ToString(); TxtAddContribution0.Text = row[19].ToString(); TxtAddEstiBud1.Text = row[20].ToString(); TxtAddNetPay1.Text = row[21].ToString(); TxtAddContribution1.Text = row[22].ToString(); TxtAddEstiBud2.Text = row[23].ToString(); TxtAddNetPay2.Text = row[24].ToString(); TxtAddContribution2.Text = row[25].ToString(); TxtCube1.Text = row[26].ToString(); TxtCube2.Text = row[27].ToString(); TxtCube3.Text = row[28].ToString(); TxtCube4.Text = row[29].ToString(); TxtCube5.Text = row[30].ToString(); TxtCube6.Text = row[31].ToString(); TxtCube7.Text = row[32].ToString(); TxtCube8.Text = row[33].ToString(); TxtCube9.Text = row[34].ToString(); TxtUCContact.Text = row[35].ToString(); TxtUCName.Text = row[36].ToString(); TxtLength.Text = row[37].ToString(); TxtWidth.Text = row[38].ToString(); TxtHeight.Text = row[39].ToString(); TxtRefer.Text = row[40].ToString(); } ConnectDb.Close(); string ProjectID = TxtProjectID.Text; string ProjectName = TxtAddProjecName.Text; string Ward = TxtAddWard.Text; string Location = TxtAddLocation.Text; TxtAddLog.AppendText("Displayed Projedt ID: " + ProjectID + " => " + ProjectName + " of " + Ward + " at " + Location); TxtAddLog.AppendText(Environment.NewLine); } }
private void BtnModify_Click(object sender, EventArgs e) { string ProjectID = TxtProjectID.Text; string FiscalYear = TxtAddFiscalYear.Text; string ProjectName = TxtAddProjecName.Text; string Ward = TxtAddWard.Text; string Location = TxtAddLocation.Text; string BudgetType = TxtAddBudgetType.Text; string WorkPermit = TxtWorkPermit.Text; string WorkStart = TxtWorkStart.Text; string FirstRunningBill = TxtFirstRunBill.Text; string FinalBill = TxtFinalBill.Text; string CurrentStatus = TxtAddCurStatus.Text; string Description = TxtDescription.Text; string Remark = TxtAddRemark.Text; string LabReport = TxtLabReport.Text; string Board = TxtBoard.Text; string ProgramBudget = TxtAddProgramBudget.Text; string Contingency = TxtAddContingency.Text; string EstimatedBudget0 = TxtAddEstiBud0.Text; string NetPayable0 = TxtAddNetPay0.Text; string Contribution0 = TxtAddContribution0.Text; string EstimatedBudget1 = TxtAddEstiBud1.Text; string NetPayable1 = TxtAddNetPay1.Text; string Contribution1 = TxtAddContribution1.Text; string EstimatedBudget2 = TxtAddEstiBud2.Text; string NetPayable2 = TxtAddNetPay2.Text; string Contribution2 = TxtAddContribution2.Text; string Cube1 = TxtCube1.Text; string Cube2 = TxtCube2.Text; string Cube3 = TxtCube3.Text; string Cube4 = TxtCube4.Text; string Cube5 = TxtCube5.Text; string Cube6 = TxtCube6.Text; string Cube7 = TxtCube7.Text; string Cube8 = TxtCube8.Text; string Cube9 = TxtCube9.Text; string UCName = TxtUCName.Text; string UCContact = TxtUCContact.Text; string Length = TxtLength.Text; string Width = TxtWidth.Text; string Height = TxtHeight.Text; string Refer = TxtRefer.Text; DialogResult dr = MessageBox.Show("Are you sure, you want to Modify?", "Modify", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { //Modify SQLiteConnection ConnectDb = new SQLiteConnection("Data Source = ProgramRecord.sqlite3"); ConnectDb.Open(); //string query = "REPLACE INTO SWAT_Iterations(ID,ProjectName,IterationNo,Parameters,Remark,Findings,FinalVerdict) VALUES('" + ID + "','" + ProjectName + "','" + IterationNo + "','" + Parameters + "','" + Remark + "','" + Findings + "','" + FinalVerdict + "')"; string query = "REPLACE INTO TableProjectRecords(ProjectID,FiscalYear,ProjectName,Ward," + "Location,BudgetType,WorkPermit,WorkStart,FirstRunningBill,FinalBill," + "CurrentStatus,Description,Remark,LabReport,Board," + "ProgramBudget,Contingency,EstimatedBudget0,NetPayable0,Contribution0," + "EstimatedBudget1,NetPayable1,Contribution1,EstimatedBudget2,NetPayable2," + "Contribution2,Cube1,Cube2,Cube3,Cube4,Cube5,Cube6,Cube7,Cube8,Cube9,UCName,UCContact," + "Length,Width,Height,Refer) " + "VALUES('" + ProjectID + "', '" + FiscalYear + "','" + ProjectName + "','" + Ward + "','" + Location + "'," + "'" + BudgetType + "','" + WorkPermit + "','" + WorkStart + "','" + FirstRunningBill + "'" + ",'" + FinalBill + "','" + CurrentStatus + "','" + Description + "','" + Remark + "'" + ",'" + LabReport + "','" + Board + "','" + ProgramBudget + "','" + Contingency + "','" + EstimatedBudget0 + "','" + NetPayable0 + "'" + ",'" + Contribution0 + "','" + EstimatedBudget1 + "','" + NetPayable1 + "','" + Contribution1 + "'" + ",'" + EstimatedBudget2 + "','" + NetPayable2 + "','" + Contribution2 + "','" + Cube1 + "'" + ",'" + Cube2 + "','" + Cube3 + "','" + Cube4 + "','" + Cube5 + "','" + Cube6 + "'" + ",'" + Cube7 + "','" + Cube8 + "','" + Cube9 + "','" + UCName + "','" + UCContact + "'" + ",'" + Length + "','" + Width + "','" + Height + "','" + Refer + "')"; SQLiteCommand Cmd = new SQLiteCommand(query, ConnectDb); Cmd.ExecuteNonQuery(); ConnectDb.Close(); TxtAddLog.AppendText("Activity: Successfully Modified Record: " + "Project ID: " + ProjectID + " " + ProjectName + " of " + Ward + " at " + Location); TxtAddLog.AppendText(Environment.NewLine); using (System.IO.StreamWriter sw = System.IO.File.AppendText(@".\Log\Log.txt")) { Text2Write = "[" + DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm:ss") + "]" + " ---> " + "MODIFY" + " ---> " + "Project ID: " + ProjectID + " " + ProjectName + " of " + Ward + " at " + Location; sw.WriteLine(Text2Write); } LblCheck.Text = "Log: "; LblCheck.ForeColor = Color.Black; LblCheckEvalFacto.Text = "Log: "; LblCheckEvalFacto.ForeColor = Color.Black; } else if (dr == DialogResult.No) { //Nothing to do } }