private void Combo_UpdatePersonal_SelectionChangeCommitted_1(object sender, EventArgs e) { if (Combo_UpdatePersonal.SelectedIndex != 0) { int keyy = ((KeyValuePair <int, string>)Combo_UpdatePersonal.SelectedItem).Key; UpdatePersonalControl person_control = new UpdatePersonalControl(); Case_Personal_Info person = person_control.getPersonalData(keyy); TextBox_FullName.Text = person.fullname; TextBox_Guardian.Text = person.guardian; TextBox_pAddress.Text = person.p_address; TextBox_cAddress.Text = person.c_address; TextBox_ContactNumber.Text = person.contact; TextBox_Age.Text = person.age; TextBox_Aadhaar.Text = person.aadhaar; byte[] imageData = person.picture; MemoryStream ms = new MemoryStream(imageData); ms.Seek(0, SeekOrigin.Begin); Picture_UpdatePhoto.Image = Image.FromStream(ms); ms.Flush(); //Primary Verifier //Secodary Verifier LabelError_Personl.Text = person.message; } }
public bool updateDetails(Case_Personal_Info personalModel) { if (checkForEmpty(personalModel)) { if (checkForChars(personalModel)) { if (insertData(personalModel)) { personalModel.message = "Details Upated Successfully!"; return(true); } else { return(false); } } else { return(false); } } else { return(false); } }
public Case_Personal_Info getPersonalData(int id) { String query = "Select * from personal_info where id=" + id; Case_Personal_Info person = new Case_Personal_Info(); try { using (SqlConnection connect = new SqlConnection(this.connection)) { connect.Open(); SqlCommand com = new SqlCommand(query, connect); SqlDataReader reader = com.ExecuteReader(); while (reader.Read()) { person.fullname = reader["fullname"].ToString(); person.guardian = reader["guardian"].ToString(); person.p_address = reader["p_address"].ToString(); person.c_address = reader["c_address"].ToString(); person.age = reader["age"].ToString(); person.contact = reader["contact_no"].ToString(); person.aadhaar = reader["aadhaar"].ToString(); person.picture = (byte[])reader["image"]; //person.verifier = reader["verifier"].ToString(); } return(person); } } catch (Exception e) { person.message = e.Message; return(person); } }
private bool insertData(Case_Personal_Info personalModel) { string Query = ""; try { using (SqlConnection connect = new SqlConnection(connection)) { if (personalModel.age == "") { personalModel.age = "0"; } Query = "UPDATE personal_info SET fullname='" + personalModel.fullname + "', guardian='" + personalModel.guardian + "', p_address='" + personalModel.p_address + "',c_address='" + personalModel.c_address + "',contact_no='" + personalModel.contact + "',aadhaar='" + personalModel.aadhaar + "',age='" + personalModel.age + "',image=@picture WHERE id=" + personalModel.caseKey; SqlCommand com = new SqlCommand(Query, connect); com.Parameters.AddWithValue("picture", personalModel.picture); connect.Open(); com.ExecuteNonQuery(); //string Query1 = "select id as lastid from personal_info where id=@@IDENTITY;"; //com = new SqlCommand(Query1, connect); //LastCaseID = (int)com.ExecuteScalar(); return(true); } } catch (Exception e) { personalModel.message = e.Message; return(false); } }
private bool contactNumberAllreadyExists(Case_Personal_Info personalModel) { try { using (SqlConnection connect = new SqlConnection(connection)) { string Query1 = "select COUNT(*) from personal_info where contact_no='" + personalModel.contact + "'"; SqlCommand com = new SqlCommand(Query1, connect); connect.Open(); int result = (int)com.ExecuteScalar(); if (result != 0) { return(true); } else { return(false); } } } catch (Exception e) { return(false); } }
private bool checkForChars(Case_Personal_Info personalModel) { Validate valid = new Validate(); if (valid.validateName(personalModel.fullname)) { if (valid.validateName(personalModel.guardian)) { if (valid.validateAddress(personalModel.p_address) && valid.validateAddress(personalModel.c_address)) { if (valid.validateContact(personalModel.contact)) { if (valid.validateNumber(personalModel.age)) { if (valid.validateAadhaar(personalModel.aadhaar) || personalModel.aadhaar == "") { return(true); } else { personalModel.message = "*Invalid Aadhaar Number"; return(false); } } else { personalModel.message = "*Age must be a number"; return(false); } } else { personalModel.message = "*Invalid Contact number format"; return(false); } } else { personalModel.message = "*Invalid Address format"; return(false); } } else { personalModel.message = "*Invalid Guardian name format"; return(false); } } else { personalModel.message = "*Invalid name format"; return(false); } }
private bool checkForEmpty(Case_Personal_Info personalModel) { if (personalModel.fullname == "" || personalModel.p_address == "" || personalModel.c_address == "" || personalModel.contact == "") { personalModel.message = "Feilds marked with * cannot be left blank"; return(false); } else { return(true); } }
public bool notifyViaSMS(Case_Personal_Info case_new) { string caseMessage = "You have been registered at Imdaad Foundation. You will be notified about Acceptence or Rejection once verification is complete.\nCoordinator Imdaad Foundation."; string verifierMessage = "You have a new Case to Verify at " + case_new.c_address + ". Your verification partner is " + case_new.secondary_verifier + ". Please get in touch for more information.\nCoordinator, Imdaad Foundation"; bool status1 = wts.SendSms(case_new.contact, caseMessage); //send to applicant bool status2 = wts.SendSms(case_new.verifier.ToString(), verifierMessage); //send to verifier bool status_secondary_verifier = wts.SendSms(case_new.secondary_verifier, verifierMessage); if (!status1 && !status2) { return(false); } else { return(true); } }
private void Button_UpdatePersonal_Click(object sender, EventArgs e) { if (Combo_UpdatePersonal.SelectedIndex != 0) { int key = ((KeyValuePair <int, string>)Combo_UpdatePersonal.SelectedItem).Key; Case_Personal_Info personalModel = new Case_Personal_Info(); personalModel.fullname = TextBox_FullName.Text; personalModel.guardian = TextBox_Guardian.Text; personalModel.p_address = TextBox_pAddress.Text; personalModel.c_address = TextBox_cAddress.Text; personalModel.contact = TextBox_ContactNumber.Text; personalModel.age = TextBox_Age.Text; personalModel.aadhaar = TextBox_Aadhaar.Text; personalModel.caseKey = key; MemoryStream stream = new MemoryStream(); Image img = ImageController.ReduceImg(Picture_UpdatePhoto.Image, 4); img.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); personalModel.picture = stream.ToArray(); stream.Flush(); UpdatePersonalControl updateControl = new UpdatePersonalControl(); if (updateControl.updateDetails(personalModel)) { MessageBox.Show(personalModel.message); } else { MessageBox.Show(personalModel.message); } } else { MessageBox.Show("Please Select a Case from the Dropdwn", "Case not Selected", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void case_personal_btn_Click(object sender, EventArgs e) { if (Combo_PersonalInfo_Verifier.SelectedIndex != 0) { Cursor.Current = Cursors.WaitCursor; Label_ErrorMessagePersonalInfo.Text = ""; Case_Personal_Info case_new = new Case_Personal_Info(); case_new.fullname = TextBox_FullName.Text; case_new.guardian = TextBox_Guardian.Text; case_new.p_address = TextBox_pAddress.Text; case_new.c_address = TextBox_cAddress.Text; case_new.age = TextBox_Age.Text; case_new.contact = TextBox_ContactNumber.Text; case_new.aadhaar = TextBox_Aadhaar.Text; //SMS Checkboxes below case_new.SMSCheckBox = CheckBox_SendSMS.Checked; case_new.verifier = Combo_PersonalInfo_Verifier.SelectedValue.ToString(); case_new.secondary_verifier = Combo_SecondaryVerifier.SelectedValue.ToString(); MemoryStream stream = new MemoryStream(); Image img = ImageController.ReduceImg(PictureBox_Photo.Image, 5); img.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); case_new.picture = stream.ToArray(); stream.Flush(); case_Control c_con = new case_Control(); if (c_con.checkForEmpty(case_new)) { if (c_con.validateForChars(case_new)) { if (c_con.InsertPersonalInf(case_new)) { if (c_con.smsChecked(case_new)) { NotifySMS sms = new NotifySMS(); if (sms.loginSMS()) { //long contact = ((KeyValuePair<long, string>)Combo_PersonalInfo_Verifier.SelectedItem).Key; if (sms.notifyViaSMS(case_new)) { MessageBox.Show("SMS Notification has been Sent Successfully", "SMS Sent", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show("The SMS Notification was not Sent. Make sure you are connected to the internet.", "SMS not Sent", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); } } else { MessageBox.Show("The SMS Login Failed.", "Message Not Sent", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); } } clearPersonalInfo(); MessageBox.Show("Registration Success. Switch tabs to fill more details.", "Successfully Registered", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); loadCases(ComboSelectCase); loadCases(combo_bank); loadCases(comboBox_otherDetails); loadCases(NeedTab_ComboBoxCases); loadCases(ComboBox_RemarksTab); //viewAll.loadGrid_Cases(); } else { Label_ErrorMessagePersonalInfo.Text = case_new.message; } } else { Label_ErrorMessagePersonalInfo.Text = case_new.message; } } else { Label_ErrorMessagePersonalInfo.Text = case_new.message; } } else { MessageBox.Show("Please Choose a Verifier for this Case", "Verifier Not Selected", MessageBoxButtons.OK, MessageBoxIcon.Information); } }