Beispiel #1
0
        protected void gvBreakdownMaintainance_OnRowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                MaintainanceBL objBreakdowneMaintainanceBL = new MaintainanceBL();
                if (e.CommandName == "Edit1")
                {
                    ViewState["Mode"] = "Edit";
                    ViewState["BreakdowneMaintainanceID"] = e.CommandArgument.ToString();
                    var objResult = objBreakdowneMaintainanceBL.Maintainance_Select(Convert.ToInt32(ViewState["BreakdowneMaintainanceID"].ToString()));
                    if (objResult != null)
                    {
                        if (objResult.Status == ApplicationResult.CommonStatusType.Success)
                        {
                            if (objResult.ResultDt.Rows.Count > 0)
                            {
                                txtEquipmentNo.Text      = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_EQUIPMENTTAGNO].ToString();
                                txtEquipmentName.Text    = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_EQUIPMENTTAGNO].ToString();
                                txtMaintainanceDate.Text = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_MAINTAINANCEDATE].ToString();
                                txtStartDate.Text        = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_STARTTIME].ToString();
                                txtEndDate.Text          = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_ENDTIME].ToString();
                                txtPartNo.Text           = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_PARTNO].ToString();
                                txtPartName.Text         = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_PARTNAME].ToString();
                                txtSection.Text          = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_SECTION].ToString();
                                txtCause.Text            = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_CAUSE].ToString();
                                txtDetailBreakdown.Text  = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_DETAILBREAKDOWN].ToString();
                                txtAction.Text           = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_ACTIONTAKEN].ToString();
                                txtRectified.Text        = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_RECTIFIEDBY].ToString();
                                txtRemark.Text           = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_REMARK].ToString();
                                txtArea.Text             = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_AREA].ToString();
                                txtDepartment.Text       = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_DEPARTMENT].ToString();

                                PanelVisibilityMode(false, true);
                            }
                            else
                            {
                                ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('You can not Update this BreakdowneMaintainance because it is in used.');</script>");
                            }
                        }
                    }
                }
                else if (e.CommandName == "Delete1")
                {
                    var objResult = objBreakdowneMaintainanceBL.Maintainance_Delete(Convert.ToInt32(e.CommandArgument.ToString()), Convert.ToInt32(Session[ApplicationSession.Userid].ToString()), DateTime.UtcNow.AddHours(5.5).ToString());
                    var objRes    = objResult.ResultDt.Rows[0]["Id"].ToString();

                    //if (objResult.Status == ApplicationResult.CommonStatusType.Success)
                    if (objRes == "Completed")
                    {
                        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Record Deleted Successfully.');</script>");
                        //  PanelVisibilityMode(true, false);
                        BindgvBreakdowneMaintainance();
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('You can not delete this BreakdowneMaintainance because it is in used.');</script>");
                    }
                }
                else if (e.CommandName == "Status1")
                {
                    var objResult = objBreakdowneMaintainanceBL.Maintainance_UpdateStatusForBreackDown(Convert.ToInt32(e.CommandArgument.ToString()), Convert.ToInt32(Session[ApplicationSession.Userid]), DateTime.UtcNow.AddHours(5.5).ToString());
                    var objRes    = objResult.ResultDt.Rows[0]["Id"].ToString();

                    //if (objResult.Status == ApplicationResult.CommonStatusType.Success)
                    if (objRes == "Completed")
                    {
                        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Breakdowne Maintainance status change Successfully.');</script>");
                        //   PanelVisibilityMode(true, false);
                        BindgvBreakdowneMaintainance();
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('You can not Status change this BreakdowneMaintainance because it is in used.');</script>");
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("Error", ex);
                ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical Problem. Contact to your Administrator.');</script>");
            }
        }
Beispiel #2
0
        protected void gvRoutineMaintainance_OnRowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                MaintainanceBL objRoutineMaintainanceBL = new MaintainanceBL();
                ClearAll();

                if (e.CommandName == "Edit1" && e.CommandArgument.ToString().Split('~')[1] != "Completed")
                {
                    ViewState["Mode"] = "Edit";
                    ViewState["RoutineMaintainanceID"] = e.CommandArgument.ToString().Split('~')[0];
                    var objResult = objRoutineMaintainanceBL.Maintainance_Select_Routine(Convert.ToInt32(ViewState["RoutineMaintainanceID"].ToString()));
                    if (objResult != null)
                    {
                        if (objResult.ResultDt.Rows.Count > 0)
                        {
                            txtEquipmentNo.Text      = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_EQUIPMENTTAGNO].ToString();
                            txtEquipmentName.Text    = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_EQUIPMENTNAME].ToString();
                            txtMaintainanceDate.Text = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_MAINTAINANCEDATE].ToString();
                            txtStartDate.Text        = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_STARTTIME].ToString();
                            txtEndDate.Text          = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_ENDTIME].ToString();
                            txtPartNo.Text           = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_PARTNO].ToString();
                            txtPartName.Text         = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_PARTNAME].ToString();
                            txtSection.Text          = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_SECTION].ToString();
                            txtArea.Text             = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_AREA].ToString();
                            txtDepartment.Text       = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_DEPARTMENT].ToString();
                            txtDueDate.Text          = objResult.ResultDt.Rows[0]["DueDate"].ToString();
                            txtNextDueDate.Text      = objResult.ResultDt.Rows[0]["NextDueDate"].ToString();
                            //txtDueDate.Text = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_DUEDATE].ToString();
                            //if (objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_NEXTDUEDATE].ToString() ==
                            //    "01/01/2015")
                            //{
                            //    txtNextDueDate.Text = "";
                            //}
                            //else
                            //{
                            //txtNextDueDate.Text = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_NEXTDUEDATE].ToString();
                            //}
                            txtAction.Text    = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_ACTIONTAKEN].ToString();
                            txtRectified.Text = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_RECTIFIEDBY].ToString();
                            txtRemark.Text    = objResult.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_REMARK].ToString();

                            PanelVisibilityMode(false, true);
                        }
                    }
                }
                else if (e.CommandName == "Delete1" && e.CommandArgument.ToString().Split('~')[1] != "Completed")
                {
                    var objResult = objRoutineMaintainanceBL.Maintainance_Delete(Convert.ToInt32(e.CommandArgument.ToString().Split('~')[0]), Convert.ToInt32(Session[ApplicationSession.Userid].ToString()), System.DateTime.UtcNow.AddHours(5.5).ToString());
                    if (objResult.Status == ApplicationResult.CommonStatusType.Success)
                    {
                        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Record Deleted Successfully.');</script>");
                        PanelVisibilityMode(true, false);
                        BindgvRoutineMaintainance();
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('You can not delete this RoutineMaintainance because it is in used.');</script>");
                    }
                }
                else if (e.CommandName == "Status1" && e.CommandArgument.ToString().Split('~')[1] != "Completed")
                {
                    ViewState["Mode"]            = "Status";
                    ViewState["RoutineStatusID"] = e.CommandArgument.ToString().Split('~')[0];
                    rfAction.Enabled             = true;
                    rfNextDueDate.Enabled        = true;
                    rfRectified.Enabled          = true;
                    var objResultStatus = objRoutineMaintainanceBL.Maintainance_Select_Routine(Convert.ToInt32(ViewState["RoutineStatusID"].ToString()));
                    if (objResultStatus != null)
                    {
                        if (objResultStatus.ResultDt.Rows.Count > 0)
                        {
                            txtEquipmentNo.Text      = objResultStatus.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_EQUIPMENTTAGNO].ToString();
                            txtEquipmentName.Text    = objResultStatus.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_EQUIPMENTNAME].ToString();
                            txtMaintainanceDate.Text = objResultStatus.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_MAINTAINANCEDATE].ToString();
                            txtStartDate.Text        = objResultStatus.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_STARTTIME].ToString();
                            txtEndDate.Text          = objResultStatus.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_ENDTIME].ToString();
                            txtPartNo.Text           = objResultStatus.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_PARTNO].ToString();
                            txtPartName.Text         = objResultStatus.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_PARTNAME].ToString();
                            txtSection.Text          = objResultStatus.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_SECTION].ToString();
                            txtArea.Text             = objResultStatus.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_AREA].ToString();
                            txtDepartment.Text       = objResultStatus.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_DEPARTMENT].ToString();
                            txtDueDate.Text          = objResultStatus.ResultDt.Rows[0]["DueDate"].ToString();
                            txtNextDueDate.Text      = objResultStatus.ResultDt.Rows[0]["NextDueDate"].ToString();
                            //txtDueDate.Text = objResultStatus.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_DUEDATE].ToString();
                            //if (objResultStatus.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_NEXTDUEDATE].ToString() ==
                            //    "01/01/2015")
                            //{
                            //    txtNextDueDate.Text = "";
                            //}
                            //else
                            //{
                            //    txtNextDueDate.Text = objResultStatus.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_NEXTDUEDATE].ToString();
                            //}
                            txtAction.Text    = objResultStatus.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_ACTIONTAKEN].ToString();
                            txtRectified.Text = objResultStatus.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_RECTIFIEDBY].ToString();
                            txtRemark.Text    = objResultStatus.ResultDt.Rows[0][MaintainanceBo.MAINTAINANCE_REMARK].ToString();
                            PanelVisibilityMode(false, true);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("Error", ex);
                ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical Problem. Contact to your Administrator.');</script>");
            }
        }