protected void Page_Load(object sender, EventArgs e) { customerTableAdapter daCustomer = new customerTableAdapter(); if (!User.Identity.IsAuthenticated) { Response.Redirect("~/Login.aspx"); } daCustomer.Update(dsCustomer); daCustomer.Fill(dsCustomer.customer); foreach (DataRow r in dsCustomer.customer) { TableRow tblRow = new TableRow(); TableCell linkButtons = new TableCell(); TableCell firstName = new TableCell(); TableCell lastName = new TableCell(); TableCell phoneNumber = new TableCell(); TableCell custAddress = new TableCell(); TableCell custCity = new TableCell(); TableCell custPostal = new TableCell(); TableCell emailAddress = new TableCell(); linkButtons.Controls.Add(new LinkButton { Text = "Edit", PostBackUrl = "Customer_Edit.aspx?val=" + r.ItemArray[0].ToString() }); linkButtons.Controls.Add(new Literal { Text = "<br />" }); linkButtons.Controls.Add(new LinkButton { Text = "Delete", PostBackUrl = "Customer_Delete.aspx?val=" + r.ItemArray[0].ToString() }); firstName.Text = r.ItemArray[1].ToString(); lastName.Text = r.ItemArray[2].ToString(); phoneNumber.Text = r.ItemArray[3].ToString(); custAddress.Text = r.ItemArray[4].ToString(); custCity.Text = r.ItemArray[5].ToString(); custPostal.Text = r.ItemArray[6].ToString(); emailAddress.Text = r.ItemArray[7].ToString(); tblRow.Cells.Add(linkButtons); tblRow.Cells.Add(firstName); tblRow.Cells.Add(lastName); tblRow.Cells.Add(phoneNumber); tblRow.Cells.Add(custAddress); tblRow.Cells.Add(custCity); tblRow.Cells.Add(custPostal); tblRow.Cells.Add(emailAddress); this.tblCustomers.Rows.Add(tblRow); } this.ddlManagement.Items[0].Attributes.Add("style", "color:#009900"); this.ddlManagement.Items[0].Attributes.Add("disabled", "disabled"); }
protected void Page_Load(object sender, EventArgs e) { if (!User.Identity.IsAuthenticated) //if not logged in { Response.Redirect("/"); } try { dsCustomer = new CustomerDataSet(); customerTableAdapter daCustomer = new customerTableAdapter(); daCustomer.Fill(dsCustomer.customer); if (Request.Cookies["ID"] != null) // Request the cookies which contaions the ID Of thr record that was carried over from the index page { id = Convert.ToInt32(Request.Cookies["ID"].Value); } if (Request.Cookies["Action"] != null && Request.Cookies["Action"].Value == "Delete") { pnlDeleteConfirm.Visible = true; lblTitle.Text = "Delete Customer"; } else { pnlDeleteConfirm.Visible = false; } } catch { return; } if (id != -1) { try { DataRow customer = dsCustomer.customer.FindByID(id); // Find the related Record and fill the fields in the page with the data if (customer != null) { this.txtID.Text = customer.ItemArray[0].ToString(); this.txtFName.Text = customer.ItemArray[1].ToString(); this.txtLName.Text = customer.ItemArray[2].ToString(); this.txtPhone.Text = customer.ItemArray[3].ToString(); this.txtAddress.Text = customer.ItemArray[4].ToString(); this.txtCity.Text = customer.ItemArray[5].ToString(); this.txtPCode.Text = customer.ItemArray[6].ToString(); this.txtEmail.Text = customer.ItemArray[7].ToString(); } else { lblStatus.Text = "Record doesn't exist"; } } catch { lblStatus.Text = "Database Error"; } } }
static NewCustomer() { customerTableAdapter daCustomer = new customerTableAdapter(); try { daCustomer.Fill(dsCustomer.customer); } catch { } }
protected void Page_Load(object sender, EventArgs e) { customerTableAdapter cust = new customerTableAdapter(); cust.Fill(dsSale.customer); DataRow[] custRows = dsSale.customer.Select(); foreach (DataRow r in custRows) { lbCustomer.Items.Add(r.ItemArray[1].ToString() + " - " + r.ItemArray[2].ToString()); } }
static OrderSearch() { dsEmmas = new EmmasDataSet(); CustomerServiceTableAdapter daCustomerService = new CustomerServiceTableAdapter(); customerTableAdapter daCustomer = new customerTableAdapter(); try { daCustomer.Fill(dsEmmas.customer); } catch { } }
private void Save() { try { customerTableAdapter daCustomer = new customerTableAdapter(); daCustomer.Update(dsCustomer.customer); // Call update method on the service adapter so it updates the table in memory ( All changes made are applied - CRUD) dsCustomer.AcceptChanges(); // Call accept method on the dataset so it update the chanmges to the database lblStatus.Text = "Record Successfully Updated"; } catch { dsCustomer.RejectChanges(); lblStatus.Text = "Unable to Update Record"; } }
static CustomerOrderSearch() { dsEmmas = new EmmasDataSet(); CustomerServiceTableAdapter daCustomerService = new CustomerServiceTableAdapter(); customerTableAdapter daCustomer = new customerTableAdapter(); try { daCustomer.Fill(dsEmmas.customer); //daCustomerOrder.Fill(dsEmmas.CustomerOrder, 1); //daCustomerOrder.Ge // daInventory.Fill(dsCustomer.CustomerInventory); } catch { } }
static PlaceSales() { dsEmmas = new EmmasDataSet(); CustomerServiceTableAdapter daCustomerService = new CustomerServiceTableAdapter(); customerTableAdapter daCustomer = new customerTableAdapter(); InventoryTableAdapter daInventory = new InventoryTableAdapter(); try { daCustomer.Fill(dsEmmas.customer); daInventory.Fill(dsEmmas.Inventory); } catch { } }
private void Save() { customerTableAdapter daCustomer = new customerTableAdapter(); try { daCustomer.Update(dsCustomer.customer); dsCustomer.AcceptChanges(); this.lblStatus.Text = "Customer Created"; Clear(); } catch { dsCustomer.RejectChanges(); this.lblStatus.Text = "Failed"; } }
private void button4_Click(object sender, EventArgs e) { try { customerTableAdapter c = new customerTableAdapter(); customerSet.customerDataTable cd = new customerSet.customerDataTable(); c.Fill(cd); allcustomer rpt = new allcustomer(); rpt.SetDataSource(cd[0].Table); Report_Viewer vd = new Report_Viewer(); vd.crystalReportViewer1.ReportSource = rpt; vd.ShowDialog(); } catch (Exception) { MessageBox.Show("There Is No Customer"); } }
protected void Page_Load(object sender, EventArgs e) { if (!User.Identity.IsAuthenticated) //if not logged in { Response.Redirect("/"); } try { dsCustomer = new CustomerDataSet(); customerTableAdapter daCustomer = new customerTableAdapter(); daCustomer.Fill(dsCustomer.customer); rows = (Session["criteria"] != null) ? dsCustomer.customer.Select(Session["criteria"].ToString()) : dsCustomer.customer.Select(); DisplayCustomer(); } catch { } //data loaded successfully }
protected void Page_Load(object sender, EventArgs e) { if (!User.Identity.IsAuthenticated) { Response.Redirect("~/Login.aspx"); } customerTableAdapter daCustomer = new customerTableAdapter(); custCityTableAdapter daCity = new custCityTableAdapter(); daCustomer.Fill(dsSales.customer); daCity.Fill(dsSales.custCity); this.ddlManagement.Items[0].Attributes.Add("style", "color:#009900"); this.ddlManagement.Items[0].Attributes.Add("disabled", "disabled"); if (this.IsPostBack) { return; } this.ddlCustomers.Items.Add("Pick a Customer..."); this.ddlCustomers.Items[0].Attributes.Add("style", "color:gray"); this.ddlCustomers.Items[0].Attributes.Add("disabled", "disabled"); this.ddlCustomers.Items[0].Selected = true; this.ddlCity.Items.Add("Pick a City..."); this.ddlCity.Items[0].Attributes.Add("style", "color:gray"); this.ddlCity.Items[0].Attributes.Add("disabled", "disabled"); this.ddlCity.Items[0].Selected = true; foreach (DataRow r in dsSales.customer) { this.ddlCustomers.Items.Add(r.ItemArray[1].ToString()); } foreach (DataRow r in dsSales.custCity) { this.ddlCity.Items.Add(r.ItemArray[0].ToString()); } }
protected void btnDeleteConfirm_Click(object sender, EventArgs e) { if (id != -1) { try { DataRow record = dsCustomer.customer.FindByID(id); // Find and add the record to tbe record variable record.Delete(); // Deletes the record in memory customerTableAdapter daCustomer = new customerTableAdapter(); // table adapter to service table (Service adapter) daCustomer.Update(record); // Call update method on the service adapter so it updates the table in memory ( All changes made are applied - CRUD) dsCustomer.AcceptChanges(); // Call accept method on the dataset so it update the chanmges to the database //Refresh the page to show the record being deleted Response.Redirect("Default.aspx"); } catch { lblStatus.Text = "Delete failed. The customer has an equipment asigned."; } } }
// End of Week Process private void doWeeklyUpdate() { //-- Truncate All Summary Records try { sqLiteConnection1.Open(); sqLiteCommand1.ExecuteNonQuery(); //drop the debtors summary table sqLiteConnection1.Close(); } catch { ; } Vectra.DataSet2TableAdapters.customerTableAdapter cda = new customerTableAdapter(); //-- Iteate all customer Transactions DataView dv = new DataView(dataSet2.customer_trans); DataView debtorView = new DataView(dataSet2.debtors_summary); DataRowView debtorsSummary; // = debtorView.AddNew(); dv.Sort = "t_cust_id"; int custId = 0; Decimal currentAmt = 0; Decimal days7 = 0; Decimal days14 = 0; Decimal days21 = 0; DateTime lastPayment = DateTime.MinValue; DateTime today = processDateTime.Value; Decimal amount; Decimal owing; Decimal openBal; foreach (DataRowView dr in dv) { if (custId.ToString() != dr["t_cust_id"].ToString()) { if (custId > 0) { // Add a new row openBal = (Decimal)cda.GetCustomerOpenBal(custId)* -1; owing = Decimal.Add(days7, currentAmt); owing = Decimal.Add(owing, days14); owing = Decimal.Add(owing, days21); owing = Decimal.Add(owing, openBal); debtorsSummary = debtorView.AddNew(); debtorsSummary["cust_id"] = custId; debtorsSummary["curAmt"] = currentAmt; debtorsSummary["days7"] = days7; debtorsSummary["days14"] = days14; debtorsSummary["days21"] = days21; debtorsSummary["Owing"] = owing; debtorsSummary["date_last_payment"] = lastPayment.ToString(); debtorsSummary["open_bal"] = openBal * -1; debtorsSummary.EndEdit(); } custId = int.Parse(dr["t_cust_id"].ToString()); currentAmt = 0; days7 = 0; days14 = 0; days21 = 0; lastPayment = DateTime.MinValue; } DateTime dt = (DateTime)new DateTimeConverter().ConvertFromString(dr["t_date"].ToString()); // Payments to subtracted, other type as is. /* if (dr["t_type"].ToString() == "Payment") { amount = Decimal.Multiply(Decimal.Parse(dr["t_amount"].ToString()), -1); if (dt > lastPayment) lastPayment = dt; } else amount = Decimal.Parse(dr["t_amount"].ToString()); */ amount = Decimal.Parse(dr["t_unpaid"].ToString()); //owing is sum of unpaid amounts if (dt >= today.AddDays(-7)) currentAmt = Decimal.Add(currentAmt,amount); else if (dt < today.AddDays(-7) && dt >= today.AddDays(-14)) days7 = Decimal.Add(days7, amount); else if (dt < today.AddDays(-14) && dt >= today.AddDays(-21)) days14 = Decimal.Add(days14, amount); else days21 = Decimal.Add(days21, amount); } //Decimal owing; if (custId > 0) { openBal = (Decimal)cda.GetCustomerOpenBal(custId) * -1; } else { openBal = 0; } owing = Decimal.Add(days7, currentAmt); owing = Decimal.Add(owing, days14); owing = Decimal.Add(owing, days21); owing = Decimal.Add(owing, openBal); // Add new row debtorsSummary = debtorView.AddNew(); debtorsSummary["cust_id"] = custId; debtorsSummary["curAmt"] = currentAmt; debtorsSummary["days7"] = days7; debtorsSummary["days14"] = days14; debtorsSummary["days21"] = days21; debtorsSummary["date_last_payment"] = lastPayment.ToString(); debtorsSummary["Owing"] = owing; debtorsSummary["open_bal"] = openBal * -1; debtorsSummary.EndEdit(); this.debtors_summaryBindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this.dataSet2); }