예제 #1
0
 private void repTimeLog_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
 {
     try
     {
         if(e.CommandName == "Delete")
         {
             order = new clsWorkOrders();
             order.cAction = "D";
             order.iOrgId = OrgId;
             order.iTimeLogId = Convert.ToInt32(e.CommandArgument);
             order.TimeLogDetails();
             order.iId = OrderId;
             order.iTechId = 0;
             dtTimeLog = order.GetTimeLogList();
             if(dtTimeLog.Rows.Count > 0)
             {
                 repTimeLog.DataSource = new DataView(dtTimeLog);
                 repTimeLog.DataBind();
                 html_tblNoneTimeLog.Visible = false;
                 lblTotalHours.Text = order.sReportDesc.Value;
                 lblTotalCosts.Text = order.sDecs.Value;
             }
             else
             {
                 repTimeLog.Visible = false;
                 html_tblNoneTimeLog.Visible = true;
                 html_trTotalHours.Visible = false;
                 html_trTotalCosts.Visible = false;
             }
         }
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = "wo_updateTimeLog.aspx?id=" + OrderId.ToString();
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(order != null)
             order.Dispose();
     }
 }
예제 #2
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                if(Request.QueryString["id"] == null)
                {
                    Session["lastpage"] = "wo_default.aspx";
                    Session["error"] = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    OrderId = Convert.ToInt32(Request.QueryString["id"]);
                    OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                }
                catch(FormatException fex)
                {
                    Session["lastpage"] = "wo_default.aspx";
                    Session["error"] = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                if(Request.QueryString["repairid"] != null)
                    RepairId = Convert.ToInt32(Request.QueryString["repairid"]);
                else
                    RepairId = 0;

                html_btnBack.Attributes.Add("onclick", "document.location='wo_viewWorkOrder.aspx?id=" + OrderId.ToString() + "&#TimeLog';");
                if (Request.Cookies.Count > 0 && Request.Cookies["bfp_navigate"] != null)
                    Header.BrdCrumbsSerialization = Request.Cookies["bfp_navigate"].Value;
                Header.AddBreadCrumb("Work Order Detail", "/wo_viewWorkOrder.aspx?id=" + OrderId.ToString());
                dtNow = DateTime.Now;
                if(!IsPostBack)
                {
                    rdiStartTime.SelectedDate = dtNow;
                    rdiStopTime.SelectedDate = dtNow;
                    order = new clsWorkOrders();
                    user = new clsUsers();
                    order.cAction = "S";
                    order.iOrgId = OrgId;
                    order.iId = OrderId;
                    user.iOrgId = OrgId;
                    user.iOrderId = OrderId;
                    user.iTypeId = (int)UserTypes.Technician;

                    DataTable dtTechList = user.GetUserListByType();
                    dtTechList.Rows[0].Delete();
                    ddlTechnicians.DataSource = new DataView(dtTechList);
                    ddlTechnicians.DataBind();

                    DataTable dtRepairList = order.GetRepairsShortList();
                    dtRepairList.Rows[0].Delete();
                    ddlRepairs.DataSource = new DataView(dtRepairList);
                    ddlRepairs.DataBind();

                    if(order.WorkOrderDetails() == -1)
                    {
                        Session["lastpage"] = this.ParentPageURL;
                        Session["error"] = _functions.ErrorMessage(120);
                        Response.Redirect("error.aspx", false);
                        return;
                    }

                    if(!user.IsTechnician(_functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true)))
                    {
                        Session["lastpage"] = this.ParentPageURL;
                        Session["error"] = _functions.ErrorMessage(131);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                    lblWorkOrderId.Text = order.daCreated.Value.ToString("yyyy-MM-dd") + "-" + order.iWorkOrderNumber.Value.ToString();
                    lblEquipId.Text = order.sEquipId.Value;
                    lblOperator.Text = order.sOperatorName.Value;
                    lblTech.Text = order.sTechName.Value;
                    if(user.GetTechnicianInfo() != -1)
                    {
                        tbHourlyRate.Text = user.dmHourlyRate.Value.ToString("F");
                        if(!user.bTechCanViewHourlyRate.Value)
                        {
                            ViewState["HourlyRate"] = user.dmHourlyRate.Value;
                            html_tblMain.Rows[12].Visible = false;
                            html_trTotalCosts.Visible = false;
                        }
                        else
                        {
                            ViewState["HourlyRate"] = null;
                            html_tblMain.Rows[12].Visible = true;
                            html_trTotalCosts.Visible = true;
                        }
                    }
                    else
                    {
                        html_trTotalCosts.Visible = true;
                        html_tblMain.Rows[12].Visible = true;
                        tbHourlyRate.Text = "0.0";
                        ViewState["HourlyRate"] = null;
                    }
                    if(ddlTechnicians.Items.FindByValue(order.iTechId.Value.ToString()) != null)
                    {
                        ddlTechnicians.SelectedValue = order.iTechId.Value.ToString();
                    }
                    else
                    {
                        ddlTechnicians.SelectedIndex = 0;
                    }
                    if(ddlRepairs.Items.FindByValue(RepairId.ToString()) != null)
                    {
                        ddlRepairs.SelectedValue = RepairId.ToString();
                    }
                    else
                    {
                        ddlRepairs.SelectedIndex = 0;
                    }
                    order.iTechId = 0;
                    dtTimeLog = order.GetTimeLogList();
                    if(dtTimeLog.Rows.Count > 0)
                    {
                        repTimeLog.DataSource = new DataView(dtTimeLog);
                        repTimeLog.DataBind();
                        html_tblNoneTimeLog.Visible = false;
                        lblTotalHours.Text = order.sReportDesc.Value;
                        lblTotalCosts.Text = order.sDecs.Value;
                    }
                    else
                    {
                        html_tblNoneTimeLog.Visible = true;
                        repTimeLog.Visible = false;
                        html_trTotalHours.Visible = false;
                        html_trTotalCosts.Visible = false;
                    }
                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = this.ParentPageURL;
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(user != null)
                    user.Dispose();
                if(order != null)
                    order.Dispose();
            }
        }