private void EditPlot_Load(object sender, EventArgs e) { try { db = new giedaEntities(); phaseBindingSource.DataSource = db.phases.ToList(); con.Select("SELECT * From plots where id =" + id + ""); DataTable dt = new DataTable(); con.sda.Fill(dt); foreach (DataRow row in dt.Rows) { title_textBox.Text = row["title"].ToString(); description_textBox.Text = row["description"].ToString(); size_textBox.Text = row["size"].ToString(); downPayment_textBox.Text = row["down_payment"].ToString(); formFee_textBox.Text = row["form_Fee"].ToString(); installment_textBox.Text = row["installments"].ToString(); quantity_textBox.Text = row["quantity"].ToString(); price_textBox.Text = row["total_price"].ToString(); phaseComboxBox.SelectedValue = Int32.Parse(row["phase_id"].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { db = new giedaEntities(); try { var plt = new plot() { title = title_textBox.Text, size = size_textBox.Text, description = description_textBox.Text, down_payment = Int32.Parse(downPayment_textBox.Text), form_fee = formFee_textBox.Text, total_price = price_textBox.Text, quantity = Int32.Parse(quantity_textBox.Text), installments = installment_textBox.Text, phase_id = Int32.Parse(phaseComboxBox.SelectedValue.ToString()), created_at = DateTime.Now, updated_at = DateTime.Now }; db.plots.Add(plt); db.SaveChanges(); MessageBox.Show("Record has been successfully added"); } catch (Exception ex) { MessageBox.Show("Error!! " + ex.Message); } }
private void editAllottees_Load(object sender, EventArgs e) { db = new giedaEntities(); plotBindingSource.DataSource = db.plots.ToList(); //name_textBox.Text= p; try { con.Select("SELECT allottees.*,plots.id as plot_id, plots.title as title FROM allotee_plots " + "INNER JOIN allottees ON allotee_plots.allottee_id = allottees.id INNER JOIN plots ON allotee_plots.plot_id = plots.id " + "where allottees.id=" + id + ""); DataTable dt = new DataTable(); con.sda.Fill(dt); foreach (DataRow row in dt.Rows) { txtName.Text = row["name"].ToString(); txtFname.Text = row["father_name"].ToString(); txtAddress.Text = row["address"].ToString(); txtCity.Text = row["city"].ToString(); txtDomicile.Text = row["domicile"].ToString(); txtNic.Text = row["nic"].ToString(); txtProvince.Text = row["province"].ToString(); txtAfNumber.Text = row["af_number"].ToString(); txtPdsNumber.Text = row["pds_number"].ToString(); ddlPlot.SelectedValue = Int32.Parse(row["plot_id"].ToString()); string appPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\allotteeProfile\"; pictureBox1.Image = Image.FromFile(appPath + row["picture"].ToString()); } } catch (Exception ex) { // MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { try { db = new giedaEntities(); var myPhase = new phase() { name = name.Text, title = title.Text, description = description.Text, created_at = DateTime.Now, updated_at = DateTime.Now }; db.phases.Add(myPhase); db.SaveChanges(); MessageBox.Show("Record Added Successfully"); this.Close(); } catch (Exception ex) { MessageBox.Show("Error !! " + ex.Message); } }
private void btnUpdate_Click(object sender, EventArgs e) { try { db = new giedaEntities(); con = new Logic.connection(); DialogResult dialogResult = MessageBox.Show("Are you sure you want to Update", "Update", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { string ext = Path.GetExtension(file_name); string pic_name = Guid.NewGuid().ToString() + ext; try { con.Update("UPDATE allottees SET name ='" + txtName.Text + "', father_name ='" + txtFname.Text + "', address ='" + txtAddress.Text + "', city ='" + txtCity.Text + "', province ='" + txtProvince.Text + "', domicile ='" + txtDomicile.Text + "', pds_number ='" + txtPdsNumber.Text + "',nic =" + long.Parse(txtNic.Text) + ", af_number ='" + txtAfNumber.Text + "',picture = '" + pic_name + "' where id=" + id); string appPath_profile = Path.GetDirectoryName(Application.ExecutablePath) + @"\allotteeProfile\"; // con.Update("Update [allotee_plots] SET plot_id=" + Int32.Parse(plotComboxBox.SelectedValue.ToString()) + " where allottee_id=" + id); File.Copy(file_path, appPath_profile + pic_name); MessageBox.Show("Updated Successfully", "Message", MessageBoxButtons.OK); } catch (Exception ex) { MessageBox.Show("Error! " + ex.Message); } } } catch (Exception ee) { MessageBox.Show("Error: " + ee.ToString()); } }
private void btn_Submit_Click(object sender, EventArgs e) { try { db = new giedaEntities(); var installment_Payment = new installment_payments() { allottee_id = id, title = "Installment ", installment_id = Int32.Parse(ddlInstallment.SelectedValue.ToString()), amount = Int32.Parse(ddlAmountPaid.Text), surcharge = Int32.Parse(ddlSurcharge.Text), paid_on = DateTime.Parse(ddlPaidDate.Value.ToShortDateString()), due_amount = Int32.Parse(ddlDueAmount.Text), due_date = DateTime.Parse(ddlDueDate.Value.ToShortDateString()), total_amount = (Int32.Parse(ddlDueAmount.Text) + Int32.Parse(ddlSurcharge.Text)), created_at = DateTime.Now, updated_at = DateTime.Now }; db.installment_payments.Add(installment_Payment); db.SaveChanges(); MessageBox.Show("Record Inserted"); } catch (Exception ee) { MessageBox.Show("Error: " + ee.ToString()); } }
private void otherPayment_Click(object sender, EventArgs e) { try { db = new giedaEntities(); var allottee_Payment = new allottee_payments() { allottee_id = id, title = txtTitle.Text, description = txtDescription.Text, amount = Int32.Parse(txtAmount.Text), surcharge = Int32.Parse(txtSurcharge.Text), paid_on = DateTime.Parse(PaidOnDate.Value.ToShortDateString()), due_amount = Int32.Parse(txtDueAmount.Text), due_date = DateTime.Parse(dueDate.Value.ToShortDateString()), created_at = DateTime.Now, updated_at = DateTime.Now }; db.allottee_payments.Add(allottee_Payment); db.SaveChanges(); MessageBox.Show("Record Inserted"); } catch (Exception ee) { MessageBox.Show("Error: " + ee.ToString()); } }
private void Allottee_load(object sender, EventArgs e) { try { txtSearch.ReadOnly = true; dataGridView1.CellValueChanged += new DataGridViewCellEventHandler(dataGridView1_CellValueChanged); dataGridView1.CurrentCellDirtyStateChanged += new EventHandler(current_Cell_State); db = new giedaEntities(); dataupdateBindingSource.DataSource = db.data_update.ToList(); dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; ddlSort.SelectedText = "Sort by "; loadData(); } catch (Exception ee) { MessageBox.Show("Error: " + ee.ToString()); } }
private void AddPlots_Load(object sender, EventArgs e) { db = new giedaEntities(); phaseBindingSource.DataSource = db.phases.ToList(); }
private void allotteeStatement_Load(object sender, EventArgs e) { db = new giedaEntities(); con = new Logic.connection(); //ReportDocument rdoc = new ReportDocument(); //con.dataGet("SELECT allotee_plots.id,allotee_plots.allottee_id FROM allotee_plots INNER JOIN allottees ON allotee_plots.allottee_id = allottees.id INNER JOIN plots ON allotee_plots.plot_id = plots.id"); //con.dataGet("SELECT id,name, father_name, nic FROM allottees"); //DataTable dt = new DataTable(); //con.sda.Fill(dt); //string appPath = Application.StartupPath; //string reportPath = @"Reports\CrystalReport1.rpt"; //string fullPath = Path.Combine(appPath, reportPath); //string path = @"C:\Users\shahid\source\repos\gieda\gieda\Reports\CrystalReport1.rpt"; //// MessageBox.Show(fullPath); //rdoc.Load(path); //rdoc.SetDataSource(dt); crystalReportViewer1.ReportSource = null; //Reports.CrystalReport1 crpt = new Reports.CrystalReport1(); Report.CrystalReport1 crpt = new Report.CrystalReport1(); // crpt.SetDataSource(dt); var query = db.allottees .Join(db.allotee_plots, c => c.id, cm => cm.allottee_id, (c, cm) => new { allottee = c, allotee_plots = cm }) .Select(x => new { x.allottee.id, x.allottee.pds_number, nic = x.allottee.nic.ToString(), x.allottee.name, x.allottee.father_name, x.allottee.address, plot_id = x.allotee_plots.plot_id }).Where(n => n.id == id).ToList(); var query2 = db.allottees.Select(c => new { id = c.id.ToString(), name = c.name, title = c.nic.ToString(), pds = c.pds_number }).ToList(); crpt.Database.Tables["allottees"].SetDataSource(query); crpt.Database.Tables["allotee_plots"].SetDataSource(db.allotee_plots.Where(c => c.allottee_id == id).ToList()); crpt.Database.Tables["plots"].SetDataSource(db.plots.Select(c => new { id = c.id.ToString(), title = c.title }).ToList()); crpt.Database.Tables["allottee_payments"].SetDataSource(db.allottee_payments.Select(c => new { id = c.id.ToString(), title = c.title, due_amount = c.due_amount, due_date = c.due_date.ToString(), amount = c.amount, paid_on = c.paid_on.ToString(), surcharge = c.surcharge, allottee_id = c.allottee_id }).Where(n => n.allottee_id == id).ToList()); crpt.Database.Tables["installment_payments"].SetDataSource(db.installment_payments.Select(c => new { id = c.id.ToString(), title = c.title, due_amount = c.due_amount, due_date = c.due_date.ToString(), amount = c.amount, paid_on = c.paid_on.ToString(), surcharge = c.surcharge, allottee_id = c.allottee_id }).Where(n => n.allottee_id == id).ToList()); con.Select("SELECT sum(due_amount) as due_amount, sum(amount) as paid_amount,sum(surcharge) FROM[dbo].[allottee_payments] where allottee_id = " + id); DataTable dt = new DataTable(); con.sda.Fill(dt); int total_due_amount = 0; int total_paid_amount = 0; foreach (DataRow row in dt.Rows) { if (row["due_amount"].ToString() != "") { total_due_amount = Int32.Parse(row["due_amount"].ToString()); total_paid_amount = Int32.Parse(row["paid_amount"].ToString()); // crpt.SetParameterValue("total_due", row["due_amount"].ToString()); } } con.Select("SELECT sum(due_amount) as due_amount, sum(amount) as paid_amount,sum(surcharge) FROM[dbo].[installment_payments] where allottee_id = " + id); DataTable dt2 = new DataTable(); con.sda.Fill(dt2); foreach (DataRow row in dt2.Rows) { if (row["due_amount"].ToString() != "") { total_due_amount += Int32.Parse(row["due_amount"].ToString()); total_paid_amount += Int32.Parse(row["paid_amount"].ToString()); } crpt.SetParameterValue("total_due", total_due_amount.ToString()); crpt.SetParameterValue("total_paid", total_paid_amount); } var margins = crpt.PrintOptions.PageMargins; crystalReportViewer1.ReportSource = crpt; crystalReportViewer1.EnableDrillDown = false; }
private void btnAdd_Click(object sender, EventArgs e) { if (doc_file_name[0] != "" && file_name != "") { try { string appPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\docs\"; // <--- string appPath_profile = Path.GetDirectoryName(Application.ExecutablePath) + @"\allotteeProfile\"; string ext = Path.GetExtension(file_name); string pic_name = Guid.NewGuid().ToString() + ext; try { db = new giedaEntities(); long num; string nic = nic_textBox.Text; num = long.Parse(nic); var addAllottee = new allottee() { name = txtName.Text, father_name = txtFname.Text, address = txtAddress.Text, city = txtCity.Text, province = txtProvince.Text, domicile = txtDomicile.Text, pds_number = txtPdsNumber.Text, nic = num, af_number = txtAfNumber.Text, picture = pic_name, created_at = DateTime.Now, updated_at = DateTime.Now }; db.allottees.Add(addAllottee); db.SaveChanges(); File.Copy(file_path, appPath_profile + pic_name); int id = addAllottee.id; for (int i = 0; i < doc_file_path.Length; i++) { string extt = Path.GetExtension(doc_file_name[i]); string doc_name = Guid.NewGuid().ToString() + ext; db = new giedaEntities(); allottee_documents allotteeDocuments = new allottee_documents() { title = "Allottee Document", document = doc_name, allotee_id = id, created_at = DateTime.Now, updated_at = DateTime.Now }; db.allottee_documents.Add(allotteeDocuments); db.SaveChanges(); } db = new giedaEntities(); var allotteePlot = new allotee_plots() { allottee_id = id, plot_id = Int32.Parse(txtPlot.SelectedValue.ToString()) }; db.allotee_plots.Add(allotteePlot); db.SaveChanges(); MessageBox.Show("Record inserted Successfully"); } catch (Exception ex) { MessageBox.Show("Invalid action " + ex.Message); } } catch (Exception ex) { MessageBox.Show("Invalid action " + ex.Message); } } else { MessageBox.Show("Kindly Upload image or documents"); } }
private void addAllottee_Load(object sender, EventArgs e) { db = new giedaEntities(); plotBindingSource.DataSource = db.plots.ToList(); }
private void Paymemt_load(object sender, EventArgs e) { db = new giedaEntities(); installmentBindingSource.DataSource = db.installments.ToList(); }
private void btn_Submit_Click(object sender, EventArgs e) { int user_id = 0; if (txtPdsNo.Text == "") { MessageBox.Show("Kindly Enter a Pds Number"); } else { con = new Logic.connection(); con.Select("select id from allottees where pds_number=" + Int32.Parse(txtPdsNo.Text)); DataTable dt = new DataTable(); con.sda.Fill(dt); foreach (DataRow row in dt.Rows) { user_id = Int32.Parse(row["id"].ToString()); } if (user_id == 0) { MessageBox.Show("Kindly enter a valid pds Number"); } else { try { string pic_name = ""; for (int i = 0; i < file_names.Length; i++) { string appPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\docs\"; string ext = Path.GetExtension(file_names[i]); pic_name = Guid.NewGuid().ToString() + ext; File.Copy(file_paths[i], appPath + pic_name); string query = "INSERT INTO allottee_documents (title, [document], allotee_id, created_at,updated_at) VALUES('Allottee Document', '" + pic_name + "'," + user_id + "," + DateTime.Now + "," + DateTime.Now + ")"; db = new giedaEntities(); allottee_documents allotteeDocuments = new allottee_documents() { title = "Allottee Document", document = pic_name, allotee_id = user_id, created_at = DateTime.Now, updated_at = DateTime.Now }; db.allottee_documents.Add(allotteeDocuments); db.SaveChanges(); } if (pic_name != "") { MessageBox.Show("Docs Uploaded"); } else { MessageBox.Show("No Image Selected"); } } catch (Exception ee) { MessageBox.Show("Error: " + ee.Message); } } } }