Пример #1
0
        private void btnAddPart_Click(object sender, System.EventArgs e)
        {
            try
            {
                OrderId = (int)ViewState["OrderId"];
                RepairId = (int)ViewState["RepairId"];
                InspectId = (int)ViewState["InspectId"];

                order = new clsWorkOrders();
                order.cAction = "U";
                order.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                order.iPartUsedId = 0;
                order.iRepairId = RepairId;
                order.iPartUsedQty = Convert.ToInt32(tbQty.Text);
                order.sPartUsedStock = tbStock.Text;
                order.sPartUsedDesc = tbDesc.Text;
                if(tbCost.Text.Length > 0)
                    order.dmPartUsedCost = Convert.ToDecimal(tbCost.Text);
                order.PartsUsedDetails();
                tbQty.Text = "";
                tbStock.Text = "";
                tbDesc.Text = "";
                tbCost.Text = "";
                dgParts.DataSource = new DataView(order.GetPartsUsedList());
                dgParts.DataBind();
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = "wo_editPartsUsed.aspx?id=" + OrderId.ToString() + "&repairid=" + RepairId.ToString() + "&inspectid=" + InspectId.ToString();
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(order != null)
                    order.Dispose();
            }
        }
Пример #2
0
        /// <summary>
        /// The common procedure what will save filled Repair 
        // and his used parts both Add mode and Edit mode.
        /// </summary>
        private void UpdateRepair(bool newRepair)
        {
            double Hours = 0.0;
            try
            {
                //				if(tbNotes.Text.Length > 0)
                //				{
                if (tbMinutes.Text.Length > 0 && Convert.ToDouble(tbMinutes.Text) >= 60)
                {
                    Header.ErrorMessage = _functions.ErrorMessage(206);
                    return;
                }
                if (tbHours.Text.Length > 0 || tbMinutes.Text.Length > 0)
                {
                    if (tbHours.Text.Length > 0) Hours += Convert.ToDouble(tbHours.Text);
                    if (tbMinutes.Text.Length > 0) Hours += Convert.ToDouble(tbMinutes.Text) / 60;
                }
                if (Hours >= 1000)
                {
                    Header.ErrorMessage = _functions.ErrorMessage(203);
                    return;
                }
                order = new clsWorkOrders();
                order.iOrgId = OrgId;
                order.iId = OrderId;
                order.sTypeService = sType;
                order.iItemId = ItemId;
                if (ServiceResult == "Repair")
                    order.iServiceResultId = (int)ServiceResults._Repaired;
                else
                    order.iServiceResultId = (int)ServiceResults._Replaced;
                if (Mode) // Add mode
                {
                    order.iRepairId = 0;
                }
                else // Edit mode
                    order.iRepairId = RepairId;

                if (RepairId == 0 && newRepair)
                {
                    order.iRepairId = preRepairId;
                    order.iInsert = true;
                }

                order.sRepairDesc = tbNotes.Text;
                order.iRepairItemId = Convert.ToInt32(ddlRepairItems.SelectedValue);
                order.iRepairCatId = Convert.ToInt32(ddlRepairCats.SelectedValue);
                if (order.UpdateRepair() == -1)
                {
                    Session["lastpage"] = sCurrentPage;
                    Session["error"] = _functions.ErrorMessage(128);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                RepairId = order.iRepairId.Value;
                // saving the parts for entered repair
                dtParts = (DataTable)ViewState["PartsUsed"];
                foreach (DataRow item in dtParts.Rows)
                {
                    if ((int)item["IsNew"] == 1)
                    {
                        order.cAction = "U";
                        order.iPartUsedId = 0;
                        order.iPartUsedQty = (int)item["Qty"];
                        order.sPartUsedStock = (string)item["Stock"];
                        order.sPartUsedDesc = (string)item["Desc"];
                        order.dmPartUsedCost = (decimal)item["Cost"];
                        order.PartsUsedDetails();
                    }
                    if ((int)item["IsDeleted"] == 1)
                    {
                        order.cAction = "D";
                        order.iPartUsedId = (int)item["Id"];
                        if (order.PartsUsedDetails() == -1)
                        {
                            Session["lastpage"] = sCurrentPage;
                            Session["error"] = _functions.ErrorMessage(125);
                            Response.Redirect("error.aspx", false);
                            return;
                        }
                    }
                }
                if (Mode && html_chNewRepair.Checked && sType == "II")
                {
                    order.iInspectItemId = ItemId;
                    foreach (RepeaterItem item in repReportedIssues.Items)
                    {
                        CheckBox cbTmp = (CheckBox)item.FindControl("cbIssue");
                        if (cbTmp.Checked && cbTmp.Enabled)
                        {
                            order.iReportedIssueId = Convert.ToInt32(cbTmp.Attributes["CommandArgument"]);
                            order.SetAssociationsIssue();
                        }
                    }
                }
                if (Hours > 0.0)
                {
                    user = new clsUsers();
                    user.iOrgId = OrgId;
                    user.iOrderId = OrderId;
                    if (user.GetTechnicianInfo() != -1)
                    {
                        order.cAction = "U";
                        order.iTimeLogId = 0;
                        order.iTechId = user.iId;
                        order.daStartTime = SqlDateTime.Null;
                        order.daStopTime = SqlDateTime.Null;
                        order.dmHours = Convert.ToDecimal(Hours);
                        order.dmHourlyRate = user.dmHourlyRate;
                        order.sNote = tbNotes.Text;
                        order.TimeLogDetails();
                    }
                }
                //				}
                //				else
                //					lblRequestor.Visible = true;
            }
            catch (FormatException fex)
            {
                Header.ErrorMessage = _functions.ErrorMessage(205);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                if (user != null)
                    user.Dispose();
                if (order != null)
                    order.Dispose();
            }
        }
Пример #3
0
 private void dgParts_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
 {
     try
     {
         if(e.CommandName == "Delete")
         {
             OrderId = (int)ViewState["OrderId"];
             RepairId = (int)ViewState["RepairId"];
             order = new clsWorkOrders();
             order.cAction = "D";
             order.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
             order.iPartUsedId = Convert.ToInt32(e.Item.Cells[0].Text);
             order.iRepairId = RepairId;
             if(order.PartsUsedDetails() == -1)
             {
                 Session["lastpage"] = "wo_editPartsUsed.aspx?id=" + OrderId.ToString() + "&repairid=" + RepairId.ToString();
                 Session["error"] = _functions.ErrorMessage(125);
                 Response.Redirect("error.aspx", false);
                 return;
             }
             dgParts.DataSource = new DataView(order.GetPartsUsedList());
             dgParts.DataBind();
         }
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = "wo_editPartsUsed.aspx?id=" + OrderId.ToString() + "&repairid=" + RepairId.ToString();
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(order != null)
             order.Dispose();
     }
 }