//save change to database private bool Save() { equipmentModifyTableAdapter equipmentModifyTableAdapter = new equipmentModifyTableAdapter(); order_lineTableAdapter order_LineTableAdapter = new order_lineTableAdapter(); service_orderTableAdapter service_OrderTableAdapter = new service_orderTableAdapter(); receiptModifyTableAdapter receiptModifyTableAdapter = new receiptModifyTableAdapter(); customerModifyTableAdapter customerModifyTableAdapter = new customerModifyTableAdapter(); try { order_LineTableAdapter.Update(dsSales.order_line); service_OrderTableAdapter.Update(dsSales.service_order); receiptModifyTableAdapter.Update(dsSales.receiptModify); equipmentModifyTableAdapter.Update(dsSales.equipmentModify); customerModifyTableAdapter.Update(dsSales.customerModify); dsSales.AcceptChanges(); dsSales.customerModify.Clear(); dsSales.receiptModify.Clear(); dsSales.order_line.Clear(); dsSales.service_order.Clear(); dsSales.equipmentModify.Clear(); customerModifyTableAdapter.Fill(dsSales.customerModify); receiptModifyTableAdapter.Fill(dsSales.receiptModify); order_LineTableAdapter.Fill(dsSales.order_line); service_OrderTableAdapter.Fill(dsSales.service_order); equipmentModifyTableAdapter.Fill(dsSales.equipmentModify); return(true); } catch { dsSales.RejectChanges(); return(false); } }
protected void btnStop_Click(object sender, EventArgs e) { if (id != -1) { try { service_orderTableAdapter daService_order = new service_orderTableAdapter(); daService_order.Fill(repairsDataSet.service_order); DataRow record = repairsDataSet.service_order.FindByid(id); // find the related Record //update the record with user's input record[2] = (DateTime.Now).ToString(); service_orderTableAdapter daServiceOrder = new service_orderTableAdapter(); daServiceOrder.Update(record); // Call update method on the service adapter so it updates the table in memory ( All changes made are applied - CRUD) repairsDataSet.AcceptChanges(); // Call accept method on the dataset so it update the chanmges to the database //Send Id to details view HttpCookie cID = new HttpCookie("ID"); // Cokkie variable named cID to hold a value cID.Value = id.ToString(); Response.Cookies.Add(cID); Session["editRedirect"] = "repairStoped"; // session for details view to see if its a redirect or not Response.Redirect("details.aspx"); // Redirect the user to Edit page on btn click } catch { this.Label1.Visible = true; this.Label1.Text = "❌ Record Updation Failed"; this.Label1.ForeColor = Color.Red; } } }
static NewRepair() { RepairsDataSet = new RepairsDataSet(); service_orderTableAdapter daServiceOrder = new service_orderTableAdapter(); try { daServiceOrder.Fill(RepairsDataSet.service_order); } catch { } }
static RepairSearch() { //load data at the beginning of the session dsRepair = new dsRepairSearch(); service_orderTableAdapter daRepair = new service_orderTableAdapter(); service_orderUpdateTableAdapter daRepairUpdate = new service_orderUpdateTableAdapter(); try { daRepair.Fill(dsRepair.service_order); daRepairUpdate.Fill(dsRepair.service_orderUpdate); } catch { } }
static SalesSearch() { dsSales = new dsSales(); customerModifyTableAdapter customerModifyTableAdapter = new customerModifyTableAdapter(); equipmentModifyTableAdapter equipmentModifyTableAdapter = new equipmentModifyTableAdapter(); receiptModifyTableAdapter receiptModifyTableAdapter = new receiptModifyTableAdapter(); order_lineTableAdapter order_LineTableAdapter = new order_lineTableAdapter(); service_orderTableAdapter service_OrderTableAdapter = new service_orderTableAdapter(); try { customerModifyTableAdapter.Fill(dsSales.customerModify); equipmentModifyTableAdapter.Fill(dsSales.equipmentModify); receiptModifyTableAdapter.Fill(dsSales.receiptModify); order_LineTableAdapter.Fill(dsSales.order_line); service_OrderTableAdapter.Fill(dsSales.service_order); } catch (Exception) { } }
//save new repair ticket private void Save() { service_orderUpdateTableAdapter daRepairUpdate = new service_orderUpdateTableAdapter(); service_orderTableAdapter daRepair = new service_orderTableAdapter(); try { daRepairUpdate.Update(dsRepair.service_orderUpdate); dsRepair.AcceptChanges(); dsRepair.service_order.Clear(); daRepair.Fill(dsRepair.service_order); this.lblSave.Text = "Data Saved. Repair ticket created."; } catch { dsRepair.RejectChanges(); this.lblSave.Text = "Unable to update"; } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } { service_orderTableAdapter daServ = new service_orderTableAdapter(); try { daServ.Fill(dsRepair.service_order); } catch { } foreach (DataRow r in dsRepair.service_order) { MakeTable(r); } } }
static Purchase() { receiptTableAdapter daReceipt = new receiptTableAdapter(); daReceipt.Fill(dsReceipt.receipt); employeeTableAdapter daEmployee = new employeeTableAdapter(); daEmployee.Fill(dsReceipt.employee); productTableAdapter daProducts = new productTableAdapter(); productTable = daProducts.GetData(); order_lineTableAdapter daLine = new order_lineTableAdapter(); daLine.Fill(dsReceipt.order_line); service_orderTableAdapter daService = new service_orderTableAdapter(); daService.Fill(dsReceipt.service_order); equipmentTableAdapter daEqu = new equipmentTableAdapter(); daEqu.Fill(dsReceipt.equipment); }
protected void Page_Load(object sender, EventArgs e) { if (User.Identity.IsAuthenticated) { pnlHide.Visible = true; } else { Response.Redirect("~/Login.aspx"); } pnlEdit.Visible = false; pnlSearch.Visible = true; btnBack.Visible = false; service_orderTableAdapter daRepair = new service_orderTableAdapter(); daRepair.Fill(dsRepair.service_order); dsRepair.GetChanges(); service_orderUpdateTableAdapter daRepairUpdate = new service_orderUpdateTableAdapter(); daRepairUpdate.Fill(dsRepair.service_orderUpdate); gvRepair.AllowSorting = false; }
protected void Page_Load(object sender, EventArgs e) { if (!User.Identity.IsAuthenticated) //if not logged in { Response.Redirect("/"); } if (Request.Cookies["ID"] != null) // Request the cookies which contaions the ID Of thr record that was carried over from the index page { this.Label1.Text = Request.Cookies["ID"].Value; } id = Convert.ToInt32(Request.Cookies["ID"].Value); if (!IsPostBack) { if (id != -1) { try { service_orderTableAdapter daServiceOrder = new service_orderTableAdapter(); daServiceOrder.Fill(repairsDataSet.service_order); DataRow record = repairsDataSet.service_order.FindByid(id); // Find the related Record and fill the fields in the page with the data if (record != null) { this.txtIssue.Text = record.ItemArray[3].ToString(); if (record.ItemArray[4].ToString() == "False") { this.radNoWarranty.Checked = true; } else { this.radInWarranty.Checked = true; } this.ddlReceipt.SelectedValue = record.ItemArray[5].ToString(); this.ddlService.SelectedValue = record.ItemArray[6].ToString(); this.ddlEquipment.SelectedValue = record.ItemArray[7].ToString(); this.ddlEmployee.SelectedValue = record.ItemArray[8].ToString(); } else { // this.Clear(); this.Label1.Visible = true; this.Label1.Text = "❌ Please Try Again"; } } catch { this.Label1.Visible = true; this.Label1.Text = "❌ Database Eror, Contact System Administrator"; this.Label1.ForeColor = Color.Red; } } } else { Repairvalidation(); } }
protected void Page_Load(object sender, EventArgs e) { if (!User.Identity.IsAuthenticated) //if not logged in { Response.Redirect("/"); } try { // Refresh the dataset so all updates are shown on page refresh RepairLookUpTableAdapter daRepair = new RepairLookUpTableAdapter(); service_orderTableAdapter daServiceOrder = new service_orderTableAdapter(); daRepair.Fill(RepairsDataSet.RepairLookUp); daServiceOrder.Fill(RepairsDataSet.service_order); } catch { this.Label1.Text = " ❌ Failed to load Data, Please Contact the system administrator"; this.Label1.ForeColor = Color.Red; return; } // Set the criteria so that the grid is refreshed Session["ServiceCriteria"] = null; Session["editRedirect"] = null; Session["createRedirect"] = null; Session["Resumed"] = null; Session["Paused"] = null; Session["deleteId"] = null; if (Session["deleteMsg"] != null) { if (Session["deleteMsg"].ToString() == "true") { this.lblDeleteMsg.Visible = true; this.lblDeleteMsg.Text = "✔ Record deleted Successfully"; Session["deleteMsg"] = null; } else { this.lblDeleteMsg.Visible = true; this.lblDeleteMsg.Text = "❌ Record not deleted. Please check if this record is related to any sales"; Session["deleteMsg"] = null; this.lblDeleteMsg.ForeColor = Color.Red; } } try { //get records rows = (Session["RepairCriteria"] != null) ? RepairsDataSet.RepairLookUp.Select(Session["RepairCriteria"].ToString()) //has criteria : RepairsDataSet.RepairLookUp.Select(); //select all } catch { this.Label1.Text = "❌ Database Error,Please try again"; this.Label1.ForeColor = Color.Red; return; } DisplayRepairTable(); }
protected void Page_Load(object sender, EventArgs e) { if (!User.Identity.IsAuthenticated) //if not logged in { Response.Redirect("/"); } if (Request.Cookies["ID"] != null) // Request the cookies which contaions the ID Of thr record that was carried over from the index page { 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 (Session["deleteId"] != null) { deleteId = Convert.ToInt32(Session["deleteId"]); this.pnlDeleteConfirm.Visible = true; } if (Session["editRedirect"] != null) { this.redirectMsg.Visible = true; if (Session["editRedirect"].ToString() == "true") { this.redirectMsg.Text = "✔ Record Successfully Updated"; } else if (Session["editRedirect"].ToString() == "repairStarted") { this.redirectMsg.Text = "✔ Repair Timer Started"; } else if (Session["editRedirect"].ToString() == "repairPaused") { this.redirectMsg.Text = "✔ Repair Timer Started"; } else if (Session["editRedirect"].ToString() == "repairResumed") { this.redirectMsg.Text = "✔ Repair Timer Resumed"; } else { this.redirectMsg.Text = "✔ Repair Timer Stoped"; } } if (Session["createRedirect"] != null) { this.redirectMsg.Visible = true; this.redirectMsg.ForeColor = Color.Green; this.redirectMsg.Text = "✔ Record Successfully Created"; } if (id != -1) { try { RepairLookUpTableAdapter daRepair = new RepairLookUpTableAdapter(); daRepair.Fill(repairsDataSet.RepairLookUp); service_orderTableAdapter daServiceOrder = new service_orderTableAdapter(); daRepair.Fill(repairsDataSet.RepairLookUp); daServiceOrder.Fill(repairsDataSet.service_order); DataRow record = repairsDataSet.RepairLookUp.FindByid(id); // Find the related Record and fill the fields in the page with the data if (record != null) { if (record.ItemArray[8].ToString() != "") { this.lblDateIn.Text = Convert.ToDateTime(record.ItemArray[7].ToString()).ToString("dddd, dd MMMM yyyy"); this.lblDateOut.Text = Convert.ToDateTime(record.ItemArray[8].ToString()).ToString("dddd, dd MMMM yyyy"); this.lblStatus.Text = "Repair Finished"; this.lblStatus.ForeColor = Color.Green; //display none of the btn if finished this.btnStop.Visible = false; this.btnStart.Visible = false; this.btnPause.Visible = false; this.btnResume.Visible = false; this.lblStart.Text = Convert.ToDateTime(record.ItemArray[7]).ToString("dddd, dd MMMM yyyy hh:mm tt"); this.lblStop.Text = Convert.ToDateTime(record.ItemArray[8]).ToString("dddd, dd MMMM yyyy hh:mm tt"); if (Session["Resumed"] != null) { this.lblpaused.Text = Session["Resumed"].ToString(); this.Label15.Visible = true; this.lblpaused.Visible = true; } if (Session["Paused"] != null) { this.lblResumed.Text = Session["Paused"].ToString(); this.Label19.Visible = true; this.lblResumed.Visible = true; } this.Label20.Visible = true; this.lblStart.Visible = true; this.Label21.Visible = true; this.lblStop.Visible = true; } else if ((record.ItemArray[8].ToString() == "") && (record.ItemArray[7].ToString() != "")) { this.lblDateIn.Text = Convert.ToDateTime(record.ItemArray[7].ToString()).ToShortDateString(); this.lblStart.Text = Convert.ToDateTime(record.ItemArray[7]).ToString("dddd, dd MMMM yyyy hh:mm tt"); this.lblDateOut.Text = "Repari in progress"; this.lblStatus.Text = "Repari in progress"; this.lblStatus.ForeColor = Color.Orange; this.btnStart.Visible = false; this.btnResume.Visible = false; this.btnStop.Visible = true; this.btnPause.Visible = true; this.Label20.Visible = true; this.lblStart.Visible = true; if (Session["Paused"] != null) { this.btnPause.Visible = false; //display pasue and stop btns if in progress this.btnResume.Visible = true; this.lblStatus.Text = "Repair Paused"; this.lblpaused.Text = Session["Paused"].ToString(); this.Label15.Visible = true; this.lblpaused.Visible = true; } if (Session["Resumed"] != null) { this.btnStart.Visible = false; this.btnPause.Visible = false; this.btnResume.Visible = false; this.btnStop.Visible = true; this.Label19.Visible = true; this.lblResumed.Visible = true; this.lblStatus.Text = "Reparir in progress"; this.lblResumed.Text = Session["Paused"].ToString(); } } else { this.lblDateIn.Text = "Repair not started"; this.lblDateOut.Text = "Repair not started"; this.lblStatus.Text = "Repair not started"; this.lblStatus.ForeColor = Color.Red; this.btnResume.Visible = false; this.btnPause.Visible = false; this.btnStop.Visible = false; this.btnStart.Visible = true; this.Label20.Visible = false; this.lblStart.Visible = false; this.Label15.Visible = false; this.lblpaused.Visible = false; this.Label19.Visible = false; this.lblResumed.Visible = false; this.Label21.Visible = false; this.lblStop.Visible = false; } this.lblssue.Text = record.ItemArray[1].ToString(); if (record.ItemArray[2].ToString() == "False") { this.lblWarranty.Text = "❌"; } else { this.lblWarranty.Text = "✔"; } this.lblService.Text = record.ItemArray[3].ToString(); this.lblEmployee.Text = record.ItemArray[5].ToString(); this.lblEquipmentType.Text = record.ItemArray[6].ToString(); this.lblEquipmentModel.Text = record.ItemArray[10].ToString(); this.lblEquipmentSerial.Text = record.ItemArray[11].ToString(); this.lblEquipmentManufacturer.Text = record.ItemArray[19].ToString(); this.lblCustomerFirst.Text = record.ItemArray[12].ToString(); this.lblCustomerLast.Text = record.ItemArray[14].ToString(); this.lblCustomerPhone.Text = record.ItemArray[13].ToString(); this.lblCustomerEmail.Text = record.ItemArray[18].ToString(); this.lblCustomerAddress.Text = record.ItemArray[15].ToString(); this.lblCustomerCity.Text = record.ItemArray[16].ToString(); this.lblCustomerPostal.Text = record.ItemArray[17].ToString(); } else { // this.Clear(); Label1.Text = "❌ Please Try Again"; } } catch { Label1.Text = "❌ Database Eror, Contact System Administrator"; } } }