private void saveToClientRequest() { if (txtclient.Text.Trim() == string.Empty || txtrequest.Text.Trim() == string.Empty) { return; } string strid = "'" + txtid.Text.Trim() + "'"; string strdocumented = "'" + chkdocumented.Checked + "'"; string stricslinterviewd = "'" + chkicslinterview.Checked + "'"; string strdtpclientinterviewdate = "'" + dtpclientinterviewdate.Value.ToString("yyyy/MM/dd") + "'"; string strmskresumptiondate = "'" + dtpresumptiondate.Value.ToString("yyyy/MM/dd") + "'"; string strRequestdescr = "'" + txtrequest.Text + "'"; string queryString = @"select distinct * from candidatecallup where recrno = " + strid + " and clientid = '"+ txtclient.Text.Trim() + "'" + " and request = '" + prv_requestcode.Trim() + "'" + " and position = '" + prv_posit.Trim() +"'" + " and reqid = '" + strReqId.Trim() + "'"; datamethods2 dthm = new datamethods2(); SqlDataReader drRecords = dthm._dataReader_NoParameter(queryString); drRecords.Read(); if (!drRecords.HasRows) { drRecords.Close(); drRecords.Dispose(); string sqlInsert = string.Empty; sqlInsert = @" insert into candidatecallup ( reqid, recrno, emptype, intlocdesr, intloccode, clientid, position, posdescr, cinterview, cintersult, remarks, intervdate, rdate, request, reqdescr, cinduction, cindsult) " + " values (" + "'" + strReqId + "'" + "," + strid + "," + "'" + cmbemploymenttype.Text.Trim() + "'" + "," + "'" + interiewlocation.Text + "'" + "," + "'" + prv_intlocation + "'" + "," + "'" + txtclient.Text + "'" + "," + "'" + prv_posit + "'" + "," + "'" + txtposition.Text + "'" + "," + "'" + chkclientinterview.Checked + "'" + "," + "'" + cmbintassessment.Text.Trim() + "'" + "," + "'" + txtremarks.Text + "'" + "," + strdtpclientinterviewdate + "," + strmskresumptiondate + "," + "'" + prv_requestcode + "'" + "," + strRequestdescr + "," + "'" + chkcinduction.Checked + "'" + "," + "'" + cmbcindsult.Text.Trim() + "'" + ")" ; int returnVal = dthm._update_Insert_NoParameter(sqlInsert); if (dthm.sqlUserError.Trim() != string.Empty) MessageBox.Show(dthm.sqlUserError); } else // do update { drRecords.Close(); drRecords.Dispose(); string sqlUpdate = string.Empty; sqlUpdate = @" update candidatecallup set " + "emptype= " + "'" + cmbemploymenttype.Text.Trim() + "'" + "," + "intlocdesr= " + "'" + interiewlocation.Text + "'" + "," + "intloccode= " + "'" + prv_intlocation + "'" + "," + "clientid= " + "'" + txtclient.Text + "'" + "," + "position= " + "'" + prv_posit + "'" + "," + "posdescr= " + "'" + txtposition.Text + "'" + "," + "cinterview= " + "'" + chkclientinterview.Checked + "'" + "," + "cintersult= " + "'" + cmbintassessment.Text.Trim() + "'" + "," + "remarks= " + "'" + txtremarks.Text + "'" + "," + "intervdate= " + strdtpclientinterviewdate + "," + "request= " + "'" + prv_requestcode + "'" + "," + "reqdescr = " + "'" + txtrequest.Text + "'" + "," + "rdate= " + strmskresumptiondate + "," + "cinduction= " + "'" + chkcinduction.Checked + "'" + "," + "cindsult= " + "'" + cmbcindsult.Text.Trim() + "'" + " where recrno = " + strid + " and reqid = '" + strReqId + "'" ; //MessageBox.Show(Convert.ToDateTime(strmskdatesentout).ToString("yyyy/MM/dd")); int returnVal = dthm._update_Insert_NoParameter(sqlUpdate); if (dthm.sqlUserError.Trim() != string.Empty) MessageBox.Show(dthm.sqlUserError); } }
private void updateDatabase1_active() { string strid = "'" + txtid.Text.Trim() + "'"; datamethods2 dthm = new datamethods2(); string sqlInsert = string.Empty; sqlInsert = @" update database1 set active = 'true' where recrno = " + strid; int returnVal = dthm._update_Insert_NoParameter(sqlInsert); if (dthm.sqlUserError.Trim() != string.Empty) MessageBox.Show(dthm.sqlUserError); }
private void saveRecords() { if (txtid.Text.Trim() == string.Empty) { MessageBox.Show("ID can't be empty!","Missing ID"); return; } if (txtusername.Text.Trim() == string.Empty) { MessageBox.Show("Username can't be empty!", "Missing Username"); return; } if (txtpassword.Text.Trim() == string.Empty) { MessageBox.Show("Password can't be empty!", "Missing Password"); return; } if (newRecords == true ) { if (txtconfirm.Text.Trim() == string.Empty) { MessageBox.Show("Confirm Password pls.", "Missing Password"); return; } if (txtpassword.Text.Trim() != txtconfirm.Text.Trim()) { MessageBox.Show("Password and Confirm Password are not the same!", "Missing Password"); return; } } string strid = "'" + txtid.Text.Trim() + "'"; string strusername = "******" + txtusername.Text + "'"; string strpassword = "******" + txtpassword.Text + "'"; string boolSuspend = "'" + chksuspended.Checked + "'"; string booldatabase1 = "'" + chkdatabase1.Checked + "'"; string booldatabase2 = "'" + chkdatabase2.Checked + "'"; string boolclientsetup = "'" + chkclients.Checked + "'"; string booldownload = "'" + chkdownload.Checked + "'"; string boolusersetup = "'" + chkusers.Checked + "'"; string boolcrequest = "'" + chkclientrequest.Checked + "'"; string boolothersetup = "'" + chksetups.Checked + "'"; string boolreports = "'" + chkreports.Checked + "'"; // // save new records if (newRecords == true) { datamethods2 dthm = new datamethods2(); string sqlInsert = string.Empty; sqlInsert = @" insert into useracct (userid,pwd,names,suspend,database1,database2, clientsetup,download,usersetup,crequest,othersetup,reports) values (" + strid + "," + strpassword + "," + strusername + "," + boolSuspend + "," + booldatabase1 + "," + booldatabase2 + "," + boolclientsetup + "," + booldownload + "," + boolusersetup + "," + boolcrequest + "," + boolothersetup + "," + boolreports + ")"; int returnVal = dthm._update_Insert_NoParameter(sqlInsert); if (dthm.sqlUserError.Trim() != string.Empty) MessageBox.Show(dthm.sqlUserError); else { MessageBox.Show("Records Saved.", "RnS Notification"); clearScreen(); } } else { datamethods2 dthm = new datamethods2(); string sqlInsert = string.Empty; sqlInsert = @" update useracct set pwd = " + strpassword + "," + " names= " + strusername + "," + " suspend = " + boolSuspend+ "," + " database1 = " + booldatabase1 + "," + " database2 = " + booldatabase2 + "," + " clientsetup = " + boolclientsetup + "," + " download= "+ booldownload + "," + " usersetup= " + boolusersetup + "," + " crequest= " + boolcrequest + "," + " othersetup= " + boolothersetup + "," + " reports= " + boolreports + " where userid = " + strid ; int returnVal = dthm._update_Insert_NoParameter(sqlInsert); if (dthm.sqlUserError.Trim() != string.Empty) MessageBox.Show(dthm.sqlUserError); else { MessageBox.Show("Update was successful Saved.", "RnS Notification"); clearScreen(); } } }
private void saveRecords() { if (txtid.Text.Trim() == string.Empty) { MessageBox.Show("ID can't be empty!", "Missing ID"); return; } if (txtsurname.Text.Trim() == string.Empty) { MessageBox.Show("Username can't be empty!", "Missing Username"); return; } if (txtfirstname.Text.Trim() == string.Empty) { MessageBox.Show("Username can't be empty!", "Missing Username"); return; } if (txtclient.Text.Trim() != string.Empty) { if (txtrequest.Text.Trim() == string.Empty) { MessageBox.Show("Specify the client request!", "Missing request"); return; } } if (txtclient.Text.Trim() != string.Empty && txtrequest.Text.Trim() != string.Empty) { // if position is not selected if (txtposition.Text == String.Empty) { MessageBox.Show("Specified Position", "RnS Notification"); return; } // checked employment infos if (chkclientinterview.Checked == true) { // if emplyment type si not selected if (cmbemploymenttype.SelectedIndex == 0) { MessageBox.Show("Specified Employment Type", "RnS Notification"); return; } // if position is not selected if (txtposition.Text == String.Empty) { MessageBox.Show("Specified Position", "RnS Notification"); return; } // if int location is not selected if (interiewlocation.Text == String.Empty) { MessageBox.Show("Specified Interview Location", "RnS Notification"); return; } // if int location is not selected if (cmbintassessment.SelectedIndex==0) { MessageBox.Show("Specified Interview Assessment", "RnS Notification"); return; } } // if int location is not selected if (chkcinduction.Checked==true && cmbcindsult.SelectedIndex == 0 ) { MessageBox.Show("Specified Induction Result", "RnS Notification"); return; } } string strentrydate = string.Empty; if (mskrecordmanagerdate.MaskFull == false) strentrydate = "'" + DateTime.Now.ToString("yyyy/MM/dd") + "'"; else strentrydate = "'" + Convert.ToDateTime(mskrecordmanagerdate.Text).ToString("yyyy/MM/dd") + "'"; string strid = "'" + txtid.Text.Trim() + "'"; string strsurname = "'" + txtsurname.Text + "'"; string strfirstname = "'" + txtfirstname.Text + "'"; string strtxtmiddlename = "'" + txtmiddlename.Text + "'"; string strinitials = "'" + txtinitials.Text + "'"; string strtitle = "'" + cmbtitle.Text + "'"; string straddress = "'" + txtaddress.Text + "'"; string strgender = "'" + cmbgender.Text + "'"; string strdob = "'" + dtpdob.Value.ToString("yyyy/MM/dd") + "'"; string strage = "'" + mskage.Text + "'"; string stremail = "'" + txtemail.Text + "'"; string strphone = "'" + mskphone.Text + "'"; string strlocation = "'" + txtlocation.Text + "'"; string strqualification = "'" + txtqualification.Text + "'"; string strgrade = "'" + txtgrade.Text + "'"; string straptested = "'" + chkaptested.Checked + "'"; string stremployed = "'" + chkcinduction.Checked + "'"; string strdocumented = "'" + chkdocumented.Checked + "'"; string stractive = "'" + chkactive.Checked + "'"; string strmedical = "'" + chkmedical.Checked + "'"; string stricslinterviewd = "'" + chkicslinterview.Checked + "'"; string strdtpclientinterviewdate = dtpclientinterviewdate.Text; string strmskresumptiondate = dtpresumptiondate.Text; string strRequestdescr = "'" + txtrequest.Text + "'"; string strModifiedBy = "'" + Program.pbUserName + "'"; // // save new records if (newRecords == true) { strModifiedBy = "'" + string.Empty + "'"; datamethods2 dthm = new datamethods2(); string sqlInsert = string.Empty; sqlInsert = @" insert into database2 (recrno,surname,firstname,middlename,initials,address, title,sex,birthdate,age,phone,email,lgadescr,qualdescr,gradedescr,aptest, documented,active,interviewed, medical, intersult, medsult, medissue, essay, essaysult, induction, inductsult, shl, manager, lgacode, gradecode, qualcode, testsult, entrydate, modifydate, modifiedby ) values (" + strid + "," + strsurname + "," + strfirstname + "," + strtxtmiddlename + "," + strinitials + "," + straddress + "," + strtitle + "," + strgender + "," + strdob + "," + strage + "," + strphone + "," + stremail + "," + strlocation + "," + strqualification + "," + strgrade + "," + straptested + "," + strdocumented + "," + stractive + "," + stricslinterviewd + "," + strmedical + "," + "'" + cmdtinterviewresult.SelectedItem.ToString().Trim() + "'" + "," + "'" + cmbmedicalresult.SelectedItem.ToString().Trim() + "'" + "," + "'" + txtmedissue.Text.Trim() + "'" + "," + "'" + chkessay.Checked + "'" + "," + "'" + cmbessayresult.SelectedItem.ToString().Trim() + "'" + "," + "'" + chkinduction.Checked + "'" + "," + "'" + cmbinductionresult.SelectedItem.ToString().Trim() + "'" + "," + "'" + chkshl.Checked + "'" + "," + "'" + txtmanager.Text.Trim() + "'" + "," + "'" + prv_location + "'" + "," + "'" + prv_grade + "'" + "," + "'" + prv_qual + "'" + "," + "'" + cmbtestresult.SelectedItem.ToString().Trim() + "'" + "," + strentrydate + "," + "'" + "" + "'" + "," + strModifiedBy + ")"; int returnVal = dthm._update_Insert_NoParameter(sqlInsert); if (dthm.sqlUserError.Trim() != string.Empty) MessageBox.Show(dthm.sqlUserError); else { saveToClientRequest(); MessageBox.Show("Records Saved.", "RnS Notification"); clearScreen(); } } else // do update { datamethods2 dthm = new datamethods2(); string sqlInsert = string.Empty; sqlInsert = @" update database2 set surname = " + strsurname + "," + " firstname= " + strfirstname + ", middlename = " + strtxtmiddlename + ", initials = " + strinitials + "," + " address = " + straddress + "," + " title = " + strtitle + "," + " sex= " + strgender + "," + " birthdate= " + strdob + "," + " age= " + strage + "," + " phone= " + strphone + "," + " email= " + stremail + "," + " lgadescr= " + strlocation + "," + " qualdescr= " + strqualification + "," + " gradedescr= " + strgrade + "," + " aptest= " + straptested + "," + " documented= " + strdocumented + "," + " active= " + stractive + "," + " medical= " + strmedical + "," + " interviewed = " + stricslinterviewd + "," + "intersult= " + "'" + cmdtinterviewresult.SelectedItem.ToString().Trim() + "'" + "," + "medsult= " + "'" + cmbmedicalresult.SelectedItem.ToString().Trim() + "'" + "," + "medissue= " + "'" + txtmedissue.Text.Trim() + "'" + "," + "essay= " + "'" + chkessay.Checked + "'" + "," + "essaysult= " + "'" + cmbessayresult.SelectedItem.ToString().Trim() + "'" + "," + "induction= " + "'" + chkinduction.Checked + "'" + "," + "inductsult= " + "'" + cmbinductionresult.SelectedItem.ToString().Trim() + "'" + "," + "shl= " + "'" + chkshl.Checked + "'" + "," + "manager= " + "'" + txtmanager.Text.Trim() + "'" + "," + "lgacode= " + "'" + prv_location.Trim() + "'" + "," + "gradecode= " + "'" + prv_grade.Trim() + "'" + "," + "qualcode= " + "'" + prv_qual.Trim() + "'" + "," + "testsult= " + "'" + cmbtestresult.SelectedItem.ToString().Trim() + "'" + "," + "entrydate= " + strentrydate + "," + "modifydate= " + "'" + DateTime.Now.ToString("yyyy/MM/dd") + "'" + "," + "modifiedby= " + "'" + Program.pbUserName + "'" + " where recrno = " + strid; int returnVal = dthm._update_Insert_NoParameter(sqlInsert); if (dthm.sqlUserError.Trim() != string.Empty) MessageBox.Show(dthm.sqlUserError); else { saveToClientRequest(); updateDatabase1_active(); MessageBox.Show("Done.", "RnS Notification"); clearScreen(); } } }
private void saveRecords() { if (txtid.Text.Trim() == string.Empty) { MessageBox.Show("ID can't be empty!", "Missing ID"); return; } if (txtsurname.Text.Trim() == string.Empty) { MessageBox.Show("Username can't be empty!", "Missing Username"); return; } if (txtfirstname.Text.Trim() == string.Empty) { MessageBox.Show("Username can't be empty!", "Missing Username"); return; } string strid = "'" + txtid.Text.Trim() + "'"; string strsurname = "'" + txtsurname.Text + "'"; string strfirstname = "'" + txtfirstname.Text + "'"; string strtxtmiddlename= "'" + txtmiddlename.Text + "'"; string strinitials = "'" + txtinitials.Text + "'"; string strtitle = "'" + cmbtitle.SelectedItem.ToString().Trim() + "'"; string straddress = "'" + txtaddress.Text + "'"; string strgender = "'" + cmbgender.SelectedItem.ToString().Trim() + "'"; string strdob = "'" + mskdob.Text + "'"; string strage = "'" + mskage.Text + "'"; string stremail = "'" + txtemail.Text + "'"; string strphone = "'" + mskphone.Text + "'"; string strlocation = "'" + txtlocation.Text + "'"; string strqualification = "'" + txtqualification.Text + "'"; string strgrade = "'" + txtgrade.Text + "'"; string strdocscreened = "'" + chkdocscreened.Checked + "'"; string straptested = "'" + chkaptested.Checked + "'"; string strtransfered = "'" + chktransfered.Checked + "'"; string strTextResult = "'" + cmbtestresult.SelectedItem.ToString().Trim() + "'"; // // save new records if (newRecords == true) { datamethods2 dthm = new datamethods2(); string sqlInsert = string.Empty; sqlInsert = @" insert into database1 (recrno,surname,firstname,middlename,initials,address, title,sex,birthdate,age,phone,email,lgadescr,qualdescr,gradedescr,screened,aptest, active,testresult,lgacode,qualcode,gradecode) values (" + strid + "," + strsurname + "," + strfirstname + "," + strtxtmiddlename + "," + strinitials + "," + straddress + "," + strtitle + "," + strgender + "," + strdob + "," + strage + "," + strphone + "," + stremail + "," + strlocation + "," + strqualification + "," + strgrade + "," + strdocscreened + "," + straptested + "," + strtransfered + "," + strTextResult + "," + "'" + prv_location + "'" + "," + "'" + prv_qual + "'" + "," + "'" + prv_grade + "'" + "," + ")"; int returnVal = dthm._update_Insert_NoParameter(sqlInsert); if (dthm.sqlUserError.Trim() != string.Empty) MessageBox.Show(dthm.sqlUserError); else { MessageBox.Show("Records Saved.", "RnS Notification"); clearScreen(); } } else { datamethods2 dthm = new datamethods2(); string sqlInsert = string.Empty; sqlInsert = @" update database1 set surname = " + strsurname + "," + " firstname= " + strfirstname + "," + " middlename = " + strtxtmiddlename + "," + " initials = " + strinitials + "," + " address = " + straddress + "," + " title = " + strtitle + "," + " sex= " + strgender + "," + " birthdate= " + strdob + "," + " age= " + strage + "," + " phone= " + strphone + "," + " email= " + stremail + "," + " lgadescr= " + strlocation + "," + " qualdescr= " + strqualification + "," + " gradedescr= " + strgrade + "," + " screened= " + strdocscreened + "," + " aptest= " + straptested + "," + " active= " + strtransfered + "," + " testresult= " + strTextResult + "," + " lgacode= " + "'" + prv_location + "'" + "," + " qualcode= " + "'" + prv_qual + "'" + "," + " gradecode= " + "'" + prv_grade + "'" + " where recrno = " + strid; int returnVal = dthm._update_Insert_NoParameter(sqlInsert); if (dthm.sqlUserError.Trim() != string.Empty) MessageBox.Show(dthm.sqlUserError); else { MessageBox.Show("Update was successful Saved.", "RnS Notification"); clearScreen(); } } }
private void saveRecords() { if (chkactive.Enabled == false) { MessageBox.Show("This request is closed", "RnS Notification"); return; } if (txtclientid.Text.Trim() == string.Empty) { MessageBox.Show("Client can't be empty!", "Missing Client ID"); return; } if (txtrequestid.Text.Trim() == string.Empty) { MessageBox.Show("Request ID can't be empty!", "Missing Request ID"); return; } //if (dtpdeadline.Text.Trim() == string.Empty) //{ // MessageBox.Show("Request Date can't be empty!", "Missing Request Date"); // return; //} if (txttitle.Text.Trim() == string.Empty) { MessageBox.Show("Request Title can't be empty!", "Missing Request Title"); return; } string strClientID = txtclientid.Text.Trim() ; string strrequestid = txtrequestid.Text ; string strrequestdate = dtprequesteddate.Value.ToShortDateString(); string strDeadeline = dtpdeadline.Value.ToShortDateString(); string strTitle= txttitle.Text; if (strrequestdate == string.Empty) strrequestdate = DateTime.Now.ToString(); string strActive = chkactive.Checked.ToString(); int _totalSaved = 0; datamethods2 dthm = new datamethods2(); for (int x = 0; x < grdClientRequest.Rows.Count; x++) { if (grdClientRequest.Rows[x].Cells[1].Value.ToString() != null && grdClientRequest.Rows[x].Cells[1].Value.ToString().Trim() != string.Empty) { string reqid = grdClientRequest.Rows[x].Cells[0].Value.ToString(); string sPosition = grdClientRequest.Rows[x].Cells[1].Value.ToString(); string qual1 = grdClientRequest.Rows[x].Cells[2].Value.ToString(); string qual2 = grdClientRequest.Rows[x].Cells[3].Value.ToString(); string qual3 = grdClientRequest.Rows[x].Cells[4].Value.ToString(); string qual4 = grdClientRequest.Rows[x].Cells[5].Value.ToString(); string RequestNo = grdClientRequest.Rows[x].Cells[6].Value.ToString(); string Location = grdClientRequest.Rows[x].Cells[7].Value.ToString(); string SupplyNo = grdClientRequest.Rows[x].Cells[8].Value.ToString(); string InterviewNo = grdClientRequest.Rows[x].Cells[9].Value.ToString(); string EmployedNo = grdClientRequest.Rows[x].Cells[10].Value.ToString(); string Remarks = grdClientRequest.Rows[x].Cells[11].Value.ToString(); Boolean newkeyid = Convert.ToBoolean(grdClientRequest.Rows[x].Cells[12].Value); string strposcode = grdClientRequest.Rows[x].Cells[13].Value.ToString(); string strlgacode = grdClientRequest.Rows[x].Cells[14].Value.ToString(); if (newkeyid == false) //existing: do Update { string sqlUpdate = string.Empty; sqlUpdate = @" update clientrequest set position = '" + sPosition + "'," + " qual1= '" + qual1 + "'," + " qual2 = '" + qual2 + "'," + " qual3 = '" + qual3 + "'," + " qual4 = '" + qual4 + "'," + " RequestNo = '" + RequestNo + "'," + " Location= '" + Location + "'," + " EmployedNo= '" + EmployedNo + "'," + " InterviewNo= '" + InterviewNo + "'," + " SupplyNo= '" + SupplyNo + "'," + " status= '" + strActive + "'," + " drequest= '" + dtpdeadline.Value.ToString("yyyy/MM/dd") + "'," + " reqdate= '" + dtprequesteddate.Value.ToString("yyyy/MM/dd") + "'," + " title= '" + strTitle + "'," + " poscode= '" + strposcode.Trim() + "'," + " lgacode = '" + strlgacode + "'," + " Remarks= '" + Remarks + "'" + " where clientid = '" + strClientID + "'" + " and requestid= '" + strrequestid + "'" + " and reqid= '" + reqid + "'"; dthm._update_Insert_NoParameter(sqlUpdate); if (dthm.sqlUserError.Trim() != string.Empty) MessageBox.Show(dthm.sqlUserError,"RnS Notification"); else { _totalSaved += 1; } } else // new: do insert { string sqlInsert = string.Empty; sqlInsert = @" Insert into clientrequest " + "(position,qual1,qual2,qual3,qual4,RequestNo, " + " poscode,lgacode,Location,EmployedNo,InterviewNo,SupplyNo,Remarks,status,drequest,reqdate,clientid,requestid,reqid,title)" + " values ('" + sPosition + "'," + "'" + qual1 + "'," + "'" + qual2 + "'," + "'" + qual3 + "'," + "'" + qual4 + "'," + "'" + RequestNo + "'," + "'" + strposcode.Trim() + "'," + "'" + strlgacode.Trim() + "'," + "'" + Location + "'," + "'" + EmployedNo + "'," + "'" + InterviewNo + "'," + "'" + SupplyNo + "'," + "'" + Remarks + "'," + "'" + strActive + "'," + "'" + dtpdeadline.Value.ToString("yyyy/MM/dd") + "'," + "'" + dtprequesteddate.Value.ToString("yyyy/MM/dd") + "'," + "'" + strClientID + "'," + "'" + strrequestid + "'," + "'" + reqid + "'," + "'" + strTitle + "'" + ")"; dthm._update_Insert_NoParameter(sqlInsert); if (dthm.sqlUserError.Trim() != string.Empty) MessageBox.Show(dthm.sqlUserError, "RnS Notification"); else { _totalSaved += 1; } } } } if (_totalSaved > 0) { MessageBox.Show(_totalSaved.ToString() + " records was committed Successfully", "RnS Notification"); clearScreen(); } else MessageBox.Show(_totalSaved.ToString() + " records was committed Successfully", "RnS Notification"); }
private void saveRecords() { if (dgvDestination.Rows.Count == 0 ) { MessageBox.Show("Move records into destination table", "RnS Notification"); return; } lblprocessing.Text = "Processing pls wait..."; string strRecrno = String.Empty; string sqlInsertwhere = string.Empty; List<string> lstRecrno = new List<string>(); int _totalSaved = 0; // get all the recrno for (int x = 0; x < dgvDestination.Rows.Count; x++) { if (dgvDestination.Rows[x].Cells[0].Value.ToString() != null && dgvDestination.Rows[x].Cells[0].Value.ToString().Trim() != string.Empty) { if (Convert.ToBoolean(dgvDestination.Rows[x].Cells[4].Value) == false) lstRecrno.Add(dgvDestination.Rows[x].Cells[0].Value.ToString().Trim()); } } if (lstRecrno.Count > 0) { sqlInsertwhere = "where recrno = '" + lstRecrno[0] + "'"; if (lstRecrno.Count - 1 > 0) { for (int x = 1; x < lstRecrno.Count; x++) { sqlInsertwhere += " or recrno = '" + lstRecrno[x] + "'"; } } } if (sqlInsertwhere.Trim() == string.Empty) // do insert { MessageBox.Show("There are no new records to save", "RnS Notification"); lblprocessing.Visible = false; return; } // save the records datamethods2 dthm = new datamethods2(); DataTable dt = new DataTable(); string sqlQueury = "Select * from recruittab "; sqlQueury += sqlInsertwhere; dt = dthm._dataTable_NoParameter_webdb(sqlQueury); if (dthm.sqlUserError == string.Empty) { if (dt.Rows.Count > 0) { _totalSaved = 0; string strLgaDescr = String.Empty; for (int x = 0; x < dt.Rows.Count; x++) { lblprocessing.Visible = true; lblprocessing.Text = "Processing Record " + (x + 1).ToString() + " of " + dt.Rows.Count.ToString(); string strSex = "Male"; if (dt.Rows[x]["sex"].ToString() == "2") { strSex = "Female"; } strLgaDescr = ""; if (dt.Rows[x]["lga"].ToString().Trim() != string.Empty ) { string sqlgetDescr = string.Empty; sqlgetDescr = "select desc1 from codestab where option1='LGACODE' and code = '" + dt.Rows[x]["lga"].ToString() + "'"; SqlDataReader dr = dthm._dataReader_NoParameter(sqlgetDescr, ConfigurationManager.ConnectionStrings["rnsConString_rims"].ConnectionString); if (dthm.sqlUserError == string.Empty) { dr.Read(); if (dr.HasRows) strLgaDescr = dr["desc1"].ToString(); } dr.Dispose(); dr.Close(); } string sqlInsert = string.Empty; sqlInsert = @" Insert into database1 " + "(recrno,surname,firstname,middlename,initials,address, " + " title,sex,age,phone,email,lgacode,lgadescr,birthdate,gradecode,gradedescr,qualcode,qualdescr,testresult,screened,aptest,active)" + " values ('" + dt.Rows[x]["recrno"].ToString() + "'," + "'" + dt.Rows[x]["surname"].ToString() + "'," + "'" + dt.Rows[x]["othernames"].ToString() + "'," + "'" + dt.Rows[x]["initials"].ToString() + "'," + "'" + " " + "'," + "'" + dt.Rows[x]["address"].ToString() + "'," + "'" + dt.Rows[x]["title"].ToString() + "'," + "'" + strSex + "'," + "'" + (DateTime.Now.Year - Convert.ToDateTime(dt.Rows[x]["birthdate"]).Year).ToString() + "'," + "'" + dt.Rows[x]["phone"].ToString() + "'," + "'" + dt.Rows[x]["email"].ToString() + "'," + "'" + dt.Rows[x]["lga"].ToString() + "'," + "'" + strLgaDescr + "'," + "'" + dt.Rows[x]["birthdate"].ToString() + "'," + "'" + " " + "'," + "'" + " " + "'," + "'" + " " + "'," + "'" + " " + "'," + "'" + " " + "'," + "'" + false + "'," + "'" + false + "'," + "'" + false + "')"; dthm._update_Insert_NoParameter(sqlInsert); if (dthm.sqlUserError.Trim() != string.Empty) MessageBox.Show(dthm.sqlUserError, "RnS Notification"); else { _totalSaved += 1; // update the webdb recruittaab string sqlUpdate = string.Empty; sqlUpdate = @" update recruittab set used = 'true'" + " where recrno = '" + dt.Rows[x]["recrno"].ToString() + "'"; dthm._update_Insert_NoParameter(sqlUpdate, ConfigurationManager.ConnectionStrings["rnsConString_webdb"].ConnectionString); try { dgvDestination.Rows[x].Cells[4].Value = true; } catch { } } } } else { MessageBox.Show("There are no records to processed", "RnS Notification"); lblprocessing.Visible = false; } } else MessageBox.Show("dthm.sqlUserError","RnS Notification"); if (_totalSaved > 0) MessageBox.Show(_totalSaved.ToString() + " records was committed Successfully", "RnS Notification"); lblprocessing.Visible = false; }
private void saveRecords_database2() { string strRecrno = String.Empty; string sqlInsertwhere = string.Empty; List<string> lstRecrno = new List<string>(); int _totalSaved = 0; datamethods2 dthm = new datamethods2(); // get all the recrno for (int x = 0; x < grdCandidate.Rows.Count; x++) { try { if (Convert.ToBoolean(grdCandidate.Rows[x].Cells[7].Value)== true && grdCandidate.Rows[x].Cells[0].Value.ToString().Trim() != string.Empty) { string strTime = DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + x.ToString(); MessageBox.Show(DateTime.Now.Date.ToString("yyyy/MM/dd")); // insert into candidtaerequest 2 string sqlInsert = string.Empty; sqlInsert = @" Insert into candidatecallup " + "(recrno,reqid,posdescr,request,clientid,position,reqdescr,dcallup)" + " values ('" + grdCandidate.Rows[x].Cells[0].Value.ToString() + "'," + "'" + strTime + "'," + "'" + lblposition.Text + "'," + "'" + txtrequestid.Text + "'," + "'" + txtclientid.Text + "'," + "'" + prv_Poscode.Trim() + "'," + "'" + lblrequestdescr.Text.Trim() + "'," + "'" + DateTime.Now.Date.ToString("yyyy/MM/dd") + "'" + ")"; dthm._update_Insert_NoParameter(sqlInsert); if (dthm.sqlUserError.Trim() != string.Empty) MessageBox.Show(dthm.sqlUserError, "RnS Notification"); else { _totalSaved += 1; } // update the status of the grid try { grdCandidate.Rows[x].Cells[8].Value = true; } catch { } } } catch { } } if (_totalSaved > 0) MessageBox.Show(_totalSaved.ToString() + " records was committed Successfully", "RnS Notification"); }
private void saveRecords_database1() { string strRecrno = String.Empty; string sqlInsertwhere = string.Empty; List<string> lstRecrno = new List<string>(); int _totalSaved = 0; // get all the recrno for (int x = 0; x < grdCandidate.Rows.Count; x++) { if (grdCandidate.Rows[x].Cells[0].Value.ToString() != null && grdCandidate.Rows[x].Cells[0].Value.ToString().Trim() != string.Empty) { if (Convert.ToBoolean(grdCandidate.Rows[x].Cells[4].Value) == true) lstRecrno.Add(grdCandidate.Rows[x].Cells[0].Value.ToString().Trim()); } } if (lstRecrno.Count > 0) { sqlInsertwhere = " where recrno = '" + lstRecrno[0] + "'"; if (lstRecrno.Count - 1 > 0) { for (int x = 1; x < lstRecrno.Count; x++) { sqlInsertwhere += " or recrno = '" + lstRecrno[x] + "'"; } } } if (sqlInsertwhere.Trim() == string.Empty) // do insert { MessageBox.Show("Select not made", "RnS Notification"); return; } // save the records datamethods2 dthm = new datamethods2(); DataTable dt = new DataTable(); string sqlQueury = "Select distinct * from database1 "; sqlQueury += sqlInsertwhere; MessageBox.Show(sqlQueury); dt = dthm._dataTable_NoParameter(sqlQueury); if (dthm.sqlUserError == string.Empty) { if (dt.Rows.Count > 0) { _totalSaved = 0; for (int x = 0; x < dt.Rows.Count; x++) { // insert into database 2 string sqlInsert = string.Empty; sqlInsert = @" Insert into database2 " + "(recrno,surname,firstname,middlename,initials,address, " + " title,sex,age,phone,email,lgacode,lgadescr,birthdate,gradecode,gradedescr,screened,aptest,active," + " qualdescr,qualcode,manager,testsult,modifiedby," + " inview,documented,medical,interviewed,shl,induction)" + " values ('" + dt.Rows[x]["recrno"].ToString() + "'," + "'" + dt.Rows[x]["surname"].ToString() + "'," + "'" + dt.Rows[x]["firstname"].ToString() + "'," + "'" + dt.Rows[x]["middlename"].ToString() + "'," + "'" + dt.Rows[x]["initials"].ToString() + "'," + "'" + dt.Rows[x]["address"].ToString() + "'," + "'" + dt.Rows[x]["title"].ToString() + "'," + "'" + dt.Rows[x]["sex"].ToString() + "'," + "'" + (DateTime.Now.Year - Convert.ToDateTime(dt.Rows[x]["birthdate"]).Year).ToString() + "'," + "'" + dt.Rows[x]["phone"].ToString() + "'," + "'" + dt.Rows[x]["email"].ToString() + "'," + "'" + dt.Rows[x]["lgacode"].ToString() + "'," + "'" + dt.Rows[x]["lgadescr"].ToString() + "'," + "'" + dt.Rows[x]["birthdate"].ToString() + "'," + "'" + " " + "'," + "'" + " " + "'," + "'" + false + "'," + "'" + false + "'," + "'" + false + "'," + "'" + " " + "'," + "'" + " " + "'," + "'" + Program.pbUserName.Trim()+ "'," + "'" + " " + "'," + "'" + " " + "'," + "'" + false + "'," + "'" + false + "'," + "'" + false + "'," + "'" + false + "'," + "'" + false + "'," + "'" + false + ")"; MessageBox.Show(sqlInsert); dthm._update_Insert_NoParameter(sqlInsert); if (dthm.sqlUserError.Trim() != string.Empty) MessageBox.Show(dthm.sqlUserError, "RnS Notification"); else { string strTime = DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + x.ToString(); // insert into candidtaerequest 2 sqlInsert = string.Empty; //sqlInsert = @" Insert into candidatecallup " // + "(recrno,reqid,position,requestid,clientid,datesent, " // + " interview,ippased,employed,remarks)" // + " values ('" + dt.Rows[x]["recrno"].ToString() + "'," // + "'" + strTime + "'," // + "'" + lblposition.Text + "'," // + "'" + txtrequestid.Text + "'," // + "'" + txtclientid.Text + "'," // + "'" + "01/01/1900" + "'," // + "'" + false + "'," // + "'" + false + "'," // + "'" + false + "'," // + "'" + " " + "'" // + ")"; sqlInsert = @" Insert into candidatecallup " + "(recrno,reqid,posdescr,requestid,clientid, position,,reqdescr)" + " values ('" + dt.Rows[x]["recrno"].ToString() + "'," + "'" + strTime + "'," + "'" + lblposition.Text + "'," + "'" + txtrequestid.Text + "'," + "'" + txtclientid.Text + "'," + "'" + prv_Poscode.Trim() + "'" + "'" + lblrequestdescr.Text.Trim() + "'" + ")"; dthm._update_Insert_NoParameter(sqlInsert); // update into database1 sqlInsert = string.Empty; sqlInsert = @" update database1 set active = 'true' where recrno = '" + dt.Rows[x]["recrno"].ToString() + "'"; dthm._update_Insert_NoParameter(sqlInsert); _totalSaved += 1; try { grdCandidate.Rows[x].Cells[8].Value = true; } catch { } } } } else MessageBox.Show("There are no records to processed", "RnS Notification"); } else MessageBox.Show(dthm.sqlUserError, "RnS Notification"); if (_totalSaved > 0) MessageBox.Show(_totalSaved.ToString() + " records was committed Successfully", "RnS Notification"); }