protected void btnDelete_Click(object sender, EventArgs e) { RepairsTbl _Repair = new RepairsTbl(); _Repair.DeleteRepair(Convert.ToInt32(lblRepairID.Text)); ReturnToPrevPage(); }
private RepairsTbl GetDataFromForm() { RepairsTbl _Repair = new RepairsTbl(); _Repair.RepairID = Convert.ToInt32(lblRepairID.Text); _Repair.CustomerID = Convert.ToInt64(ddlCompany.SelectedValue); _Repair.ContactName = tbxContactName.Text; _Repair.ContactEmail = tbxContactEmail.Text; _Repair.JobCardNumber = tbxJobCardNumber.Text; _Repair.MachineTypeID = Convert.ToInt32(ddlEquipTypes.SelectedValue); _Repair.MachineSerialNumber = tbxMachineSerialNumber.Text; _Repair.SwopOutMachineID = Convert.ToInt32(ddlSwopOutMachine.SelectedValue); _Repair.MachineConditionID = Convert.ToInt32(ddlMachineCondtion.SelectedValue); _Repair.TakenFrother = cbxTakenFrother.Checked; _Repair.TakenBeanLid = cbxTakenBeanLid.Checked; _Repair.TakenWaterLid = cbxTakenWaterLid.Checked; _Repair.BrokenFrother = cbxBrokenFrother.Checked; _Repair.BrokenBeanLid = cbxBrokenBeanLid.Checked; _Repair.BrokenWaterLid = cbxBrokenWaterLid.Checked; _Repair.RepairFaultID = Convert.ToInt32(ddlRepairFault.SelectedValue); _Repair.RepairFaultDesc = tbxRepairFaultDesc.Text; _Repair.RepairStatusID = Convert.ToInt32(ddlRepairStatuses.SelectedValue); _Repair.Notes = tbxNotes.Text; // now the static _Repair.DateLogged = Convert.ToDateTime(lblDateLogged.Text).Date; _Repair.LastStatusChange = Convert.ToDateTime(lblLastChanged.Text).Date; _Repair.RelatedOrderID = Convert.ToInt32(lblRelatedOrderID.Text); return(_Repair); }
void UpdateRecord() { RepairsTbl _Repair = (RepairsTbl)Session[CONST_SESSION_REPAIRDATA]; int _NewStatusId = Convert.ToInt32(ddlRepairStatuses.SelectedValue); if (_Repair.RepairStatusID != _NewStatusId) { // if the status has changed then update and send an email //string resultStr = _Repair.UpdateRepairStatus(_NewStatusId, _Repair.RepairID); _Repair.RepairStatusID = _NewStatusId; _Repair.HandleAndUpdateRepairStatusChange(_Repair); } }
private void PutDataFromForm(int pRepairID) { RepairsTbl _Repair = new RepairsTbl(); _Repair = _Repair.GetRepairById(pRepairID); if (_Repair != null) { lblRepairID.Text = _Repair.RepairID.ToString(); // make sure the data is bound to the drop down lists. ddlCompany.DataBind(); ddlEquipTypes.DataBind(); ddlMachineCondtion.DataBind(); ddlRepairFault.DataBind(); ddlRepairStatuses.DataBind(); ddlSwopOutMachine.DataBind(); // now assign data ddlCompany.SelectedValue = _Repair.CustomerID.ToString(); tbxContactName.Text = _Repair.ContactName; tbxContactEmail.Text = _Repair.ContactEmail; tbxJobCardNumber.Text = _Repair.JobCardNumber; ddlEquipTypes.SelectedValue = _Repair.MachineTypeID.ToString(); tbxMachineSerialNumber.Text = _Repair.MachineSerialNumber; ddlSwopOutMachine.SelectedValue = _Repair.SwopOutMachineID.ToString(); ddlMachineCondtion.SelectedValue = _Repair.MachineConditionID.ToString(); cbxTakenFrother.Checked = _Repair.TakenFrother; cbxTakenBeanLid.Checked = _Repair.TakenBeanLid; cbxTakenWaterLid.Checked = _Repair.TakenWaterLid; cbxBrokenFrother.Checked = _Repair.BrokenFrother; cbxBrokenBeanLid.Checked = _Repair.BrokenBeanLid; cbxBrokenWaterLid.Checked = _Repair.BrokenWaterLid; ddlRepairFault.SelectedValue = _Repair.RepairFaultID.ToString(); tbxRepairFaultDesc.Text = _Repair.RepairFaultDesc; ddlRepairStatuses.SelectedValue = _Repair.RepairStatusID.ToString(); tbxNotes.Text = _Repair.Notes; // now the static lblDateLogged.Text = String.Format("{0:d}", _Repair.DateLogged); lblLastChanged.Text = String.Format("{0:d}", _Repair.LastStatusChange); lblRelatedOrderID.Text = _Repair.RelatedOrderID.ToString(); Session[CONST_SESSION_REPAIRSTATUSID] = _Repair.RepairStatusID; } }
private void PutDataFromForm(int pRepairID) { RepairsTbl _Repair = new RepairsTbl(); _Repair = _Repair.GetRepairById(pRepairID); if (_Repair != null) { lblRepairID.Text = _Repair.RepairID.ToString(); // make sure the data is bound to the drop down lists. ltrlComapny.Text = GetCompanyName(_Repair.CustomerID); ltrlMachine.Text = GetMachineDesc(_Repair.MachineTypeID); ddlRepairStatuses.DataBind(); // now assign data ltrlMachineSerialNumber.Text = _Repair.MachineSerialNumber; ddlRepairStatuses.SelectedValue = _Repair.RepairStatusID.ToString(); // now the static Session[CONST_SESSION_REPAIRDATA] = _Repair; } }
void UpdateRecord() { RepairsTbl _Repair = GetDataFromForm(); string resultStr = _Repair.UpdateRepair(_Repair, _Repair.RepairID); int _OldStatusId = (Session[CONST_SESSION_REPAIRSTATUSID] != null) ? (int)Session[CONST_SESSION_REPAIRSTATUSID] : 0; if (String.IsNullOrWhiteSpace(resultStr)) { ltrlStatus.Text = "Record Updated"; // if the status has changed then send an email if (_Repair.RepairStatusID != _OldStatusId) { _Repair.HandleAndUpdateRepairStatusChange(_Repair); Session[CONST_SESSION_REPAIRSTATUSID] = _OldStatusId; } } else { ltrlStatus.Text = resultStr; upnlRepairDetail.Update(); } }
//protected void MarkTempOrdersItemsAsDone(long pCustomerID) //{ // string _SQLUpdate = "UPDATE OrdersTbl SET OrdersTbl.Done = True WHERE CustomderId = " + pCustomerID.ToString() + // "AND EXISTS (SELECT RequiredByDate FROM TempOrdersHeaderTbl " + // " WHERE (RequiredByDate = OrdersTbl.RequiredByDate))"; // TrackerDb _TrackerDb = new TrackerDb(); // _TrackerDb.ExecuteNonQuerySQL(_SQLUpdate); // // ResetCustomerReminderCount(pCustomerId); // //''''''''''''' // //' mark orders as done - should do this last // //''' // //lblStatus.Caption = "Marking orders as done" // //dbs.Execute ("UPDATE OrdersTbl SET OrdersTbl.Done = True " + _ // // "WHERE (((Exists (Select TempOrdersTbl.OrderId from TempOrdersTbl where " + _ // // "TempOrdersTbl.OrderId = OrdersTbl.OrderId))<>False))") // //''''''' // //' Resetting count and enable, only if coffee item // //' // //dbs.Execute ("UPDATE DISTINCTROW CustomersTbl SET ReminderCount = 0, enabled = True WHERE CustomerID=" + lblCustomerID.Caption) //} // Logic for processing order as done: // 1. move items consumed from temp aable to the items consumed for the contact // 2. using the summary of the data on the form do calculations around predictions // on when the contact needs items again. // 3. Notify client of items deliverred (add option to contacts table) // 4. return to the previous page. protected void btnDone_Click(object sender, EventArgs e) { const long MAXQTYINSTOCK = 50; TrackerTools _TrackerTools = new TrackerTools(); _TrackerTools.SetTrackerSessionErrorString(string.Empty); Label _CustomerIDLabel = (Label)(fvOrderDone.FindControl("CustomerIDLabel")); Label _CustomerNameLabel = (Label)(fvOrderDone.FindControl("CompanyNameLabel")); long _CustomerID = Convert.ToInt64(_CustomerIDLabel.Text); TextBox _OrderDateLabel = (TextBox)(fvOrderDone.FindControl("ByDateTextBox")); DateTime _OrderDate = Convert.ToDateTime(_OrderDateLabel.Text); double _CoffeeStock = 0; // store the current data for display later: ClientUsageTbl _OriginalUsageDAL = new ClientUsageTbl(); ClientUsageTbl _OriginalUsageData = _OriginalUsageDAL.GetUsageData(_CustomerID); if (!string.IsNullOrEmpty(_TrackerTools.GetTrackerSessionErrorString())) { Response.Write(_TrackerTools.GetTrackerSessionErrorString()); } TempOrdersDAL _TempOrdersDAL = new TempOrdersDAL(); // bool _HasCoffeeInTempOrder = _TempOrdersDAL.HasCoffeeInTempOrder(); if (!string.IsNullOrEmpty(_TrackerTools.GetTrackerSessionErrorString())) { Response.Write(_TrackerTools.GetTrackerSessionErrorString()); } /* NEED TO ADD Code to check for zzname */ // check cup count not in wrong place if ((tbxStock.Text.Length > 0) && (Convert.ToDouble(tbxStock.Text) > MAXQTYINSTOCK)) { showMessageBox _MsgBox = new showMessageBox(this.Page, "Stock seems high", "The stock quantity appears very high please check that you have enterred the correct value in kilograms.</b>"); } else { _CoffeeStock = String.IsNullOrEmpty(tbxStock.Text) ? 0 : Math.Round(Convert.ToDouble(tbxStock.Text), 2); // First we must get the latest cup count ltrlStatus.Text = "Calculating the latest cup count"; GeneralTrackerDbTools _GeneralTrackerDb = new GeneralTrackerDbTools(); GeneralTrackerDbTools.LineUsageData _LatestCustomerData = _GeneralTrackerDb.GetLatestUsageData(_CustomerID, TrackerTools.CONST_SERVTYPECOFFEE); if (!string.IsNullOrEmpty(_TrackerTools.GetTrackerSessionErrorString())) { showMessageBox _smb = new showMessageBox(this.Page, "Tracker Session Error", _TrackerTools.GetTrackerSessionErrorString()); } bool _bIsActual = (tbxCount.MaxLength > 0); // if there is a cup count long _lCupCount = 0; if (tbxCount.MaxLength > 0) { _lCupCount = Convert.ToInt64(tbxCount.Text); } // Calculate the cup count if we do not have it on the form or they entered a value that makes no sense if ((_lCupCount < 1) || (_lCupCount < _LatestCustomerData.LastCount)) { ltrlStatus.Text = "Calculating the latest est cup count"; _lCupCount = _GeneralTrackerDb.CalcEstCupCount(_CustomerID, _LatestCustomerData, _HasCoffeeInTempOrder); _bIsActual = false; } // clear any repairs that may have been logged RepairsTbl _Repairs = new RepairsTbl(); _Repairs.SetStatusDoneByTempOrder(); //' add items to consumption log _lCupCount = AddItemsToClientUsageTbl(_CustomerID, _bIsActual, _lCupCount, _CoffeeStock, _OrderDate); // update the last cup count for the client if (!_OriginalUsageDAL.UpdateUsageCupCount(_CustomerID, _lCupCount)) { showMessageBox _smb = new showMessageBox(this.Page, "Error", "Error updating last count"); ltrlStatus.Text = "error updating last count"; } // now update the predictions _GeneralTrackerDb.UpdatePredictions(_CustomerID, _lCupCount); // update all items in the order table as done that are done _TempOrdersDAL.MarkTempOrdersItemsAsDone(); // reset count and enable client _GeneralTrackerDb.ResetCustomerReminderCount(_CustomerID, _HasCoffeeInTempOrder); if (_HasCoffeeInTempOrder) { _GeneralTrackerDb.SetClientCoffeeOnlyIfInfo(_CustomerID); } // may need to add another check here to handle if they have ordered maintenance stuff. switch (rbtnSendConfirm.SelectedValue) { case "none": break; case "postbox": SendDeliveredEmail(_CustomerID, "placed your order in the your post box."); break; case "dispatched": SendDeliveredEmail(_CustomerID, "dispatched you order."); break; case "done": SendDeliveredEmail(_CustomerID, "delivered your order and it has signed for."); break; default: break; } // destroy the temp table that we used to create this temp orders _TempOrdersDAL.KillTempOrdersData(); ShowResults(_CustomerNameLabel.Text, _CustomerID, _OriginalUsageData); } }