private void button2_Click(object sender, EventArgs e) { DialogResult resu = MessageBox.Show("Are you sure to cancel operation?", "Okay", MessageBoxButtons.YesNo); if (resu == DialogResult.Yes) { All_Clear(); this.Controls.Clear(); tab_residents tr = new tab_residents(); this.Controls.Add(tr); tr.ID = this.ID.Trim(); tr.Dock = DockStyle.Fill; tr.Show(); timer1.Stop(); SqlDataAdapter da = new SqlDataAdapter("delete from resident where family_id is null", Connection.con); SqlCommandBuilder cd = new SqlCommandBuilder(da); DataTable dt = new DataTable(); da.Fill(dt); LFMdata.DataSource = dt; UpdateStatus(); Reset(); } else if (resu == DialogResult.No) { } }
private void clearBtn_Click(object sender, EventArgs e) { FMPIclear(); this.Refresh(); this.Controls.Clear(); tab_residents tr = new tab_residents(); this.Controls.Add(tr); // tr.ID = this.ID.Trim(); tr.ID = ID.Trim(); tr.Dock = DockStyle.Fill; tr.Show(); }
private void button1_Click(object sender, EventArgs e) { if (familyName.Text == "" || houseHoldNum.Text == "" || Purok.Text == "" || Barangay.Text == "" || City.Text == "" || home == "" || residentStat == "" || lotype == "" || lengthOR == "" || waterS == "" || waterC == "" || garbase == "" || cr == "") { MessageBox.Show("Please dont leave empty spaces"); } else { string fac = ""; try { if (facility.CheckedItems.Count > 0) { for (int i = 0; i < facility.CheckedItems.Count; i++) { if (fac == "") { fac = facility.CheckedItems[i].ToString(); } else { fac += ", " + facility.CheckedItems[i].ToString(); } } if (LFMdata.DataSource == null) { MessageBox.Show("No Resident Added!"); } else { Connection con = new Connection(); con.Connect(); SqlCommand cmd = new SqlCommand(); SqlCommand cmd2 = new SqlCommand(); cmd.CommandText = "INSERT INTO FAMILY(FAMILY_NAME,FAMILY_HOUSEHOLD_NUM,FAMILY_ZONE,FAMILY_STREET,FAMILY_BARANGAY,FAMILY_CITY,FAMILY_DATE_REGISTERED,FAMILY_HOME_STRUCTURE,FAMILY__RESIDENTIAL_STATUS,FAMILY_LOT_TYPE,FAMILY_RESIDENCY_LENGTH,FAMILY_WATER_SOURCE,FAMILY_WATER_PAYMENT,FAMILY_CR,FAMILY_GARBAGE_SYSTEM,FAMILY_COMMUNITY_FACILITIES,STAFF_ID)" + " VALUES(@family, @hh, @zone,@street,@barangay,@city,@dateR,@hs,@rs,@lt,@rl,@ws,@wp,@cr,@gs,@cf,@sid)"; cmd2.CommandText = "UPDATE RESIDENT SET FAMILY_ID =(SELECT MAX(FAMILY_ID) FROM FAMILY) WHERE FAMILY_ID IS NULL"; cmd.Connection = Connection.con; cmd2.Connection = Connection.con; cmd.Parameters.AddWithValue("@family", familyName.Text); cmd.Parameters.AddWithValue("@hh", houseHoldNum.Text); cmd.Parameters.AddWithValue("@zone", Purok.Text); cmd.Parameters.AddWithValue("@street", street.Text); cmd.Parameters.AddWithValue("@barangay", Barangay.Text); cmd.Parameters.AddWithValue("@city", City.Text); cmd.Parameters.AddWithValue("@dateR", dateTaken.Text); cmd.Parameters.AddWithValue("@hs", home); cmd.Parameters.AddWithValue("@rs", residentStat); cmd.Parameters.AddWithValue("@lt", lotype); cmd.Parameters.AddWithValue("@rl", lengthOR); cmd.Parameters.AddWithValue("@ws", waterS); cmd.Parameters.AddWithValue("@wp", waterC); cmd.Parameters.AddWithValue("@cr", cr); cmd.Parameters.AddWithValue("@gs", garbase); cmd.Parameters.AddWithValue("@cf", fac); cmd.Parameters.AddWithValue("@sid", ID); cmd.ExecuteNonQuery(); cmd2.ExecuteNonQuery(); MessageBox.Show("Family Added Successfully"); this.Controls.Clear(); tab_residents tr = new tab_residents(); this.Controls.Add(tr); tr.ID = this.ID.Trim(); tr.Dock = DockStyle.Fill; tr.Show(); SqlDataAdapter da = new SqlDataAdapter("select RESIDENT_LNAME AS Lastname,RESIDENT_FNAME AS Firstname,RESIDENT_MNAME AS MI,RESIDENT_AGE AS Age,RESIDENT_POSITION AS Position,RESIDENT_FAMILY_HEAD AS Family_Head from resident where family_id is null", Connection.con); SqlCommandBuilder cd = new SqlCommandBuilder(da); DataTable dt = new DataTable(); da.Fill(dt); LFMdata.DataSource = dt; timer1.Stop(); All_Clear(); Reset(); } } else { MessageBox.Show("You should select facilities around your area"); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.ToString()); } } }
private void saveResBtn_Click(object sender, EventArgs e) { try { string healthStat = ""; string healthProb = ""; string vaccine = ""; if (fname.Text == "" || lname.Text == "" || YrLvl.Text == "" || skill.Text == "") { MessageBox.Show("Please fill up all forms"); } else { try { if (healthProblems.CheckedItems.Count > 0 && healthStatus.CheckedItems.Count > 0 && vaccineTaken.CheckedItems.Count > 0) { for (int i = 0; i < healthProblems.CheckedItems.Count; i++) { if (healthProb == "") { healthProb = healthProblems.CheckedItems[i].ToString(); } else { healthProb += ", " + healthProblems.CheckedItems[i].ToString(); } } for (int i = 0; i < healthStatus.CheckedItems.Count; i++) { if (healthStat == "") { healthStat = healthStatus.CheckedItems[i].ToString(); } else { healthStat += ", " + healthStatus.CheckedItems[i].ToString(); } } for (int i = 0; i < vaccineTaken.CheckedItems.Count; i++) { if (vaccine == "") { vaccine = vaccineTaken.CheckedItems[i].ToString(); } else { vaccine += ", " + vaccineTaken.CheckedItems[i].ToString(); } } Connection con = new Connection(); con.Connect(); SqlCommand cmd = new SqlCommand(); SqlCommand scmd = new SqlCommand(); cmd.CommandText = "INSERT INTO resident(RESIDENT_FNAME,RESIDENT_MNAME,RESIDENT_LNAME,RESIDENT_CNUM,RESIDENT_DOB,RESIDENT_CIVIL_REGESTERED,RESIDENT_MARITAL,RESIDENT_POSITION,RESIDENT_FAMILY_HEAD,RESIDENT_GENDER,RESIDENT_EDUC_STATUS,RESIDENT_EDUC_LVL,RESIDENT_EDUC_GRADE,RESIDENT_SPECIALSKILL,RESIDENT_SOURCE_OF_FUND,RESIDENT_JOB_TYPE,RESIDENT_INCOME,RESIDENT_HEALTH_PROBLEM,RESIDENT_HEALTH_STATUS,RESIDENT_VACCINE,RESIDENT_IMAGE,RESIDENT_FINGERPRINT,STAFF_ID,FAMILY_ID) " + "VALUES(@fname,@mname,@lname,@cnum,@dob,@civilReg,@marital,@position,@head,@gender,@eduStatus,@eduLevel,@gradeLevel,@skill,@sof,@job,@income,@healthProb,@healthStat,@vaccine,@pic,@finger,@sid,@fid)"; scmd.CommandText = "update resident set resident_age = datediff(YY, resident_dob,GETDATE())"; cmd.Connection = Connection.con; scmd.Connection = Connection.con; if (res_Image.Image == null) { MessageBox.Show("Please take a photo"); } else if (fingerPrint1.Image == null) { MessageBox.Show("Please scan your fingerprint!"); } else if (cnum.Text.Length < 11 || cnum.Text.Length > 11) { MessageBox.Show("Check your Contact Number!"); cnum.Focus(); } else if (mi.Text.Length > 1) { MessageBox.Show("Initials should be 1 character!"); mi.Focus(); } else if (healthStatus.CheckedItems.Count >= 2) { MessageBox.Show("Only choose 1 health status!"); healthStatus.Focus(); } else if (healthProblems.CheckedItems.Count > 3) { MessageBox.Show("Only choose 5 health problems!"); healthProblems.Focus(); } else { UpdateStatus(); switch (Enroller.TemplateStatus) { case DPFP.Processing.Enrollment.Status.Ready: // report success and stop capturing { // byte[] btarr = null; // Enroller.Template.Serialize(ref btarr); MemoryStream fingerprint = new MemoryStream(); Enroller.Template.Serialize(fingerprint); fingerprint.Position = 0; BinaryReader br = new BinaryReader(fingerprint); byte[] bytes = br.ReadBytes((Int32)fingerprint.Length); try { MemoryStream stream = new MemoryStream(); fingerprint.Position = (0); res_Image.Image = resizeImage(res_Image.Image, new Size(177, 151)); res_Image.Image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); //fingerPrint1.Image.Save(fingerprint, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] pic = stream.ToArray(); // byte[] fic = br.ReadBytes((Int32)fingerprint.Length); cmd.Parameters.AddWithValue("@fname", fname.Text); cmd.Parameters.AddWithValue("@mname", mi.Text); cmd.Parameters.AddWithValue("@lname", lname.Text); cmd.Parameters.AddWithValue("@cnum", cnum.Text); cmd.Parameters.AddWithValue("@dob", DOB.Value); cmd.Parameters.AddWithValue("@gender", gender.Text); cmd.Parameters.AddWithValue("@civilReg", civilRegStat.Text); cmd.Parameters.AddWithValue("@marital", maritalStatus.Text); cmd.Parameters.AddWithValue("@position", familyPos.Text); cmd.Parameters.AddWithValue("@head", familyHead.Text); cmd.Parameters.AddWithValue("@eduStatus", eduStat.Text); cmd.Parameters.AddWithValue("@eduLevel", eduLvl.Text); cmd.Parameters.AddWithValue("@gradeLevel", YrLvl.Text); cmd.Parameters.AddWithValue("@skill", skill.Text); cmd.Parameters.AddWithValue("@income", monthlyIncome.Text); cmd.Parameters.AddWithValue("@sof", sourceOfFund.Text); cmd.Parameters.AddWithValue("@job", jobType.Text); cmd.Parameters.AddWithValue("@healthProb", healthProb); cmd.Parameters.AddWithValue("@healthStat", healthStat); cmd.Parameters.AddWithValue("@vaccine", vaccine); cmd.Parameters.AddWithValue("@finger", bytes); cmd.Parameters.AddWithValue("@pic", pic); cmd.Parameters.AddWithValue("@sid", ID); cmd.Parameters.AddWithValue("@fid", FID); cmd.ExecuteNonQuery(); scmd.ExecuteNonQuery(); MessageBox.Show("Resident Added Successfully"); FMPIclear(); myCamera.Stop(); res_Image.Image = null; fingerPrint1.Image = null; Reset(); this.Controls.Clear(); tab_residents tr = new tab_residents(); this.Controls.Add(tr); // tr.ID = this.ID.Trim(); tr.ID = ID.Trim(); tr.Dock = DockStyle.Fill; tr.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message + ex.ToString()); Reset(); } break; } case DPFP.Processing.Enrollment.Status.Failed: // report failure and restart capturing { Enroller.Clear(); cp.StopCapture(); UpdateStatus(); OnTemplate(null); cp.StartCapture(); break; } } } } else { MessageBox.Show("Dont leave empty spaces"); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.ToString()); } } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.ToString()); } }
private void saveResBtn_Click(object sender, EventArgs e) { try { string healthStat = ""; string healthProb = ""; string vaccine = ""; if (fname.Text == "" || lname.Text == "") { MessageBox.Show("Please fill up all forms"); } else { try { if (healthProblems.CheckedItems.Count > 0 && healthStatus.CheckedItems.Count > 0 && vaccineTaken.CheckedItems.Count > 0) { for (int i = 0; i < healthProblems.CheckedItems.Count; i++) { if (healthProb == "") { healthProb = healthProblems.CheckedItems[i].ToString(); } else { healthProb += ", " + healthProblems.CheckedItems[i].ToString(); } } for (int i = 0; i < healthStatus.CheckedItems.Count; i++) { if (healthStat == "") { healthStat = healthStatus.CheckedItems[i].ToString(); } else { healthStat += ", " + healthStatus.CheckedItems[i].ToString(); } } for (int i = 0; i < vaccineTaken.CheckedItems.Count; i++) { if (vaccine == "") { vaccine = vaccineTaken.CheckedItems[i].ToString(); } else { vaccine += ", " + vaccineTaken.CheckedItems[i].ToString(); } } Connection con = new Connection(); con.Connect(); SqlCommand cmd = new SqlCommand(); SqlCommand cmd2 = new SqlCommand(); SqlCommand scmd = new SqlCommand(); cmd2.CommandText = "UPDATE RESIDENT SET RESIDENT_FNAME = @fname,RESIDENT_MNAME = @mname,RESIDENT_LNAME = @lname ,RESIDENT_CNUM = @cnum,RESIDENT_DOB = @dob,RESIDENT_CIVIL_REGESTERED = @civilReg,RESIDENT_MARITAL =@marital ,RESIDENT_POSITION =@position,RESIDENT_FAMILY_HEAD = @head,RESIDENT_GENDER = @gender,RESIDENT_EDUC_STATUS=@eduStatus ,RESIDENT_EDUC_LVL =@eduLevel,RESIDENT_EDUC_GRADE=@gradeLevel,RESIDENT_SPECIALSKILL =@skill,RESIDENT_SOURCE_OF_FUND = @sof ,RESIDENT_JOB_TYPE = @job,RESIDENT_INCOME = @income,RESIDENT_HEALTH_PROBLEM = @healthProb ,RESIDENT_HEALTH_STATUS = @healthStat,RESIDENT_VACCINE = @vaccine ,STAFF_ID = @sid WHERE RESIDENT_ID = '" + RID + "' "; cmd.CommandText = "UPDATE RESIDENT SET RESIDENT_FNAME = @fname,RESIDENT_MNAME = @mname,RESIDENT_LNAME = @lname ,RESIDENT_CNUM = @cnum,RESIDENT_DOB = @dob,RESIDENT_CIVIL_REGESTERED = @civilReg,RESIDENT_MARITAL =@marital ,RESIDENT_POSITION =@position,RESIDENT_FAMILY_HEAD = @head,RESIDENT_GENDER = @gender,RESIDENT_EDUC_STATUS=@eduStatus ,RESIDENT_EDUC_LVL =@eduLevel,RESIDENT_EDUC_GRADE=@gradeLevel,RESIDENT_SPECIALSKILL =@skill,RESIDENT_SOURCE_OF_FUND = @sof ,RESIDENT_JOB_TYPE = @job,RESIDENT_INCOME = @income,RESIDENT_HEALTH_PROBLEM = @healthProb ,RESIDENT_HEALTH_STATUS = @healthStat,RESIDENT_VACCINE = @vaccine,RESIDENT_IMAGE = @pic ,STAFF_ID = @sid WHERE RESIDENT_ID = '" + RID + "' "; scmd.CommandText = "update resident set resident_age = datediff(YY, resident_dob,GETDATE())"; cmd.Connection = Connection.con; cmd2.Connection = Connection.con; scmd.Connection = Connection.con; if (cnum.Text.Length > 11) { MessageBox.Show("Check your Contact Number!"); cnum.Focus(); } else if (DOB.Value >= DateTime.Now) { MessageBox.Show("Check your Date of Birth!"); } else if (mi.Text.Length > 1) { MessageBox.Show("Initials should be 1 character!"); mi.Focus(); } else if (healthStatus.CheckedItems.Count >= 2) { MessageBox.Show("Only choose 1 health status!"); healthStatus.Focus(); } else if (healthProblems.CheckedItems.Count > 3) { MessageBox.Show("Only choose 5 health problems!"); healthProblems.Focus(); } else if (res_Image.Image == null) { cmd2.Parameters.AddWithValue("@fname", fname.Text); cmd2.Parameters.AddWithValue("@mname", mi.Text); cmd2.Parameters.AddWithValue("@lname", lname.Text); cmd2.Parameters.AddWithValue("@cnum", cnum.Text); cmd2.Parameters.AddWithValue("@dob", DOB.Value); cmd2.Parameters.AddWithValue("@gender", gender.Text); cmd2.Parameters.AddWithValue("@civilReg", civilRegStat.Text); cmd2.Parameters.AddWithValue("@marital", maritalStatus.Text); cmd2.Parameters.AddWithValue("@position", familyPos.Text); cmd2.Parameters.AddWithValue("@head", familyHead.Text); cmd2.Parameters.AddWithValue("@eduStatus", eduStat.Text); cmd2.Parameters.AddWithValue("@eduLevel", eduLvl.Text); cmd2.Parameters.AddWithValue("@gradeLevel", YrLvl.Text); cmd2.Parameters.AddWithValue("@skill", skill.Text); cmd2.Parameters.AddWithValue("@income", monthlyIncome.Text); cmd2.Parameters.AddWithValue("@sof", sourceOfFund.Text); cmd2.Parameters.AddWithValue("@job", jobType.Text); cmd2.Parameters.AddWithValue("@healthProb", healthProb); cmd2.Parameters.AddWithValue("@healthStat", healthStat); cmd2.Parameters.AddWithValue("@vaccine", vaccine); cmd2.Parameters.AddWithValue("@sid", ID); cmd2.ExecuteNonQuery(); scmd.ExecuteNonQuery(); MessageBox.Show("Saved"); FMPIclear(); this.Refresh(); myCamera.Stop(); this.Controls.Clear(); tab_residents tr = new tab_residents(); this.Controls.Add(tr); // tr.ID = this.ID.Trim(); tr.ID = ID.Trim(); tr.Dock = DockStyle.Fill; tr.Show(); } else { MemoryStream stream = new MemoryStream(); res_Image.Image = resizeImage(res_Image.Image, new Size(177, 151)); res_Image.Image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); //fingerPrint1.Image.Save(fingerprint, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] pic = stream.ToArray(); // byte[] fic = br.ReadBytes((Int32)fingerprint.Length); cmd.Parameters.AddWithValue("@fname", fname.Text); cmd.Parameters.AddWithValue("@mname", mi.Text); cmd.Parameters.AddWithValue("@lname", lname.Text); cmd.Parameters.AddWithValue("@cnum", cnum.Text); cmd.Parameters.AddWithValue("@dob", DOB.Value); cmd.Parameters.AddWithValue("@gender", gender.Text); cmd.Parameters.AddWithValue("@civilReg", civilRegStat.Text); cmd.Parameters.AddWithValue("@marital", maritalStatus.Text); cmd.Parameters.AddWithValue("@position", familyPos.Text); cmd.Parameters.AddWithValue("@head", familyHead.Text); cmd.Parameters.AddWithValue("@eduStatus", eduStat.Text); cmd.Parameters.AddWithValue("@eduLevel", eduLvl.Text); cmd.Parameters.AddWithValue("@gradeLevel", YrLvl.Text); cmd.Parameters.AddWithValue("@skill", skill.Text); cmd.Parameters.AddWithValue("@income", monthlyIncome.Text); cmd.Parameters.AddWithValue("@sof", sourceOfFund.Text); cmd.Parameters.AddWithValue("@job", jobType.Text); cmd.Parameters.AddWithValue("@healthProb", healthProb); cmd.Parameters.AddWithValue("@healthStat", healthStat); cmd.Parameters.AddWithValue("@vaccine", vaccine); cmd.Parameters.AddWithValue("@pic", pic); cmd.Parameters.AddWithValue("@sid", ID); cmd.ExecuteNonQuery(); scmd.ExecuteNonQuery(); MessageBox.Show("Saved"); FMPIclear(); this.Refresh(); myCamera.Stop(); this.Controls.Clear(); tab_residents tr = new tab_residents(); this.Controls.Add(tr); // tr.ID = this.ID.Trim(); tr.ID = ID.Trim(); tr.Dock = DockStyle.Fill; tr.Show(); } } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.ToString()); } } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.ToString()); } }