Exemple #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserBO"] == null)
        {
            Response.Redirect("Login.aspx", false);
        }
        else
        {
            if (!IsPostBack)
            {
                _userBO = new UserBO();
                _userBO = (UserBO)Session["UserBO"];
                if (Request["request"] != null)
                {
                    Session["WmsId"] = int.Parse(Request["request"]);
                }

                //Session["WmsId"] = 1;
                if (Session["WmsId"] != null && Convert.ToInt32(Session["WmsId"]) != 0)
                {
                    lblWmsIdValue.Text = Session["WmsId"].ToString();
                    var WmsId = Convert.ToInt32(Session["WmsId"]);
                    FillStatusDropDown(WmsId);
                    FillRequestDetails(WmsId);
                }
                else
                {
                    Form_Request.ChangeMode(FormViewMode.Insert);
                }
            }
        }
    }
Exemple #2
0
    private void FillRequestDetails(int wmsId)
    {
        try
        {
            _rqstbl = new requestBL();
            var ds = _rqstbl.GetRequestDetail(wmsId);
            if (ds.Tables[0].Rows.Count > 0)
            {
                Form_Request.DataSource = ds.Tables[0];
                Form_Request.DataBind();
                lblCurrentStatusValue.Text = ds.Tables[0].Rows[0]["StatusName"].ToString();
                if (Convert.ToInt16(ds.Tables[0].Rows[0]["StatusId"]) == 3 || Convert.ToInt16(ds.Tables[0].Rows[0]["StatusId"]) == 4)
                {
                    var btnEditRequest = (Button)Form_Request.FindControl("btnEditRequest");
                    btnEditRequest.Visible = false;
                }
                else
                {
                    var btnEditRequest = (Button)Form_Request.FindControl("btnEditRequest");
                    if (btnEditRequest != null)
                    {
                        btnEditRequest.Visible = true;
                    }
                }

                Session["wmsId"] = wmsId;
            }
        }
        catch (Exception ex)
        {
            throw;
        }
    }
Exemple #3
0
    protected void Form_Request_ItemInserting(object sender, FormViewInsertEventArgs e)
    {
        try
        {
            _rqstbo            = CreateRequest();
            _rqstbo.InsUpdFlag = 0;
            _rqstbo.statusId   = 1;
            _rqstbo.assignedTo = 1;


            if (Session["UserBO"] == null)
            {
                Response.Redirect("Login.aspx", false);
            }
            else
            {
                _userBO = new UserBO();
                _userBO = (UserBO)Session["UserBO"];
                // change after adding branch drop down for admin
                if (_userBO.RoleID == 1)
                {
                    _rqstbo.branchId = 1;
                }
                else
                {
                    _rqstbo.branchId = _userBO.BranchID;
                }
            }
            //   change after login page

            _rqstbl = new requestBL();
            var tranid = _rqstbl.insertUpdateRequest(_rqstbo);
            if (!(tranid.Equals(0)))
            {
                lblMessage.Text    = "Request placed succesfully";
                lblMessage.Visible = true;
                Form_Request.ChangeMode(FormViewMode.ReadOnly);
                FillRequestDetails(tranid);
                FillStatusDropDown(tranid);
                lblWmsIdValue.Text = tranid.ToString();
            }
            else
            {
                lblMessage.Text    = "Request creation failed. Please try again";
                lblMessage.Visible = true;
            }
        }
        catch (Exception ex)
        {
            Session["wmsId"] = null;
            throw;
        }
        finally
        {
            _rqstbo = null;
            _rqstbl = null;
        }
    }
Exemple #4
0
    protected void Form_Request_ModeChanging(object sender, FormViewModeEventArgs e)
    {
        try
        {
            Form_Request.ChangeMode(e.NewMode);

            if (Session["wmsId"] != null)
            {
                var wmsid = Convert.ToInt32(Session["wmsId"]);
                FillRequestDetails(wmsid);
            }
            else
            {
                Form_Request.ChangeMode(FormViewMode.Insert);
            }

            if (e.NewMode == FormViewMode.Insert)
            {
                Session["wmsId"] = null;
            }

            if (e.NewMode == FormViewMode.Edit)
            {
                var ddlpriority = (DropDownList)Form_Request.FindControl("ddlPriorityEdit");
                // var ddl = (DropDownList)Form_Request.FindControl("ddlPriorityEdit");
                var lbl = (Label)Form_Request.FindControl("lblPriorityEditValue");
                ddlpriority.SelectedIndex = ddlpriority.Items.IndexOf(ddlpriority.Items.FindByText(lbl.Text));

                var ddlAffectingEdit      = (DropDownList)Form_Request.FindControl("ddlAffectingEdit");
                var lblAffectingEditValue = (Label)Form_Request.FindControl("lblAffectingEditValue");
                ddlAffectingEdit.SelectedIndex = ddlAffectingEdit.Items.IndexOf(ddlAffectingEdit.Items.FindByText(lblAffectingEditValue.Text));

                var ddlFloorEdit      = (DropDownList)Form_Request.FindControl("ddlFloorEdit");
                var lblFloorEditValue = (Label)Form_Request.FindControl("lblFloorEditValue");
                // ddlFloorEdit.SelectedIndex = ddlFloorEdit.Items.IndexOf(ddlFloorEdit.Items.FindByText(lblFloorEditValue.Text));
                ddlFloorEdit.SelectedValue = lblFloorEditValue.Text;

                var ddlSectionEdit      = (DropDownList)Form_Request.FindControl("ddlSectionEdit");
                var lblSectionEditValue = (Label)Form_Request.FindControl("lblSectionEditValue");
                ddlSectionEdit.SelectedIndex = ddlSectionEdit.Items.IndexOf(ddlSectionEdit.Items.FindByText(lblSectionEditValue.Text));

                var      chkCategoryEdit = (CheckBoxList)Form_Request.FindControl("chkCategoryEdit");
                var      Category        = (Label)Form_Request.FindControl("lblCategoryEditValue");
                String[] categories      = Category.Text.Split(new[] { ", " }, StringSplitOptions.None);
                foreach (ListItem item in chkCategoryEdit.Items)
                {
                    item.Selected = categories.Contains(item.Text);
                }
            }
        }
        catch (Exception ex)
        {
            throw;
        }
    }
Exemple #5
0
    private requestBO CreateRequest()
    {
        _rqstbo = new requestBO();
        try
        {
            var ddlpriority = (DropDownList)Form_Request.FindControl("ddlPriorityEdit");
            _rqstbo.priorityId = Convert.ToInt16(ddlpriority.SelectedValue);

            var ddlAffecting = (DropDownList)Form_Request.FindControl("ddlAffectingEdit");
            _rqstbo.affectOperation = ddlAffecting.SelectedValue;

            var txtScope = (TextBox)Form_Request.FindControl("txtScopeEdit");
            _rqstbo.scope = txtScope.Text;

            var ddlFloor = (DropDownList)Form_Request.FindControl("ddlFloorEdit");
            _rqstbo.floor = Convert.ToInt16(ddlFloor.SelectedValue);

            var ddlSection = (DropDownList)Form_Request.FindControl("ddlSectionEdit");
            _rqstbo.sectionId = Convert.ToInt16(ddlSection.SelectedValue);

            var txtOtherSection = (TextBox)Form_Request.FindControl("txtOtherSectionEdit");
            _rqstbo.otherSection = txtOtherSection.Text;

            var    chkCategory = (CheckBoxList)Form_Request.FindControl("chkCategoryEdit");
            string category    = String.Join(", ", chkCategory.Items.Cast <ListItem>().Where(i => i.Selected));
            _rqstbo.categoryId = category;

            var txtRemarks = (TextBox)Form_Request.FindControl("txtRemarksEdit");
            _rqstbo.remarks = txtRemarks.Text;

            var txtRequestor = (TextBox)Form_Request.FindControl("txtRequestorEdit");
            _rqstbo.requestor = txtRequestor.Text;

            _rqstbo.createdDate = DateTime.Now;
            _rqstbo.statusId    = 1;
            _rqstbo.assignedTo  = 1;
        }
        catch (Exception ex)
        {
            lblMessage.Visible = true;
            lblMessage.Text    = "Something went wrong please try again";
        }
        return(_rqstbo);
    }
Exemple #6
0
    private void FillCheckBox(string chk, string selectQuery, string table, string condition)
    {
        try
        {
            var chkname = (CheckBoxList)Form_Request.FindControl(chk);

            _rqstbl = new requestBL();

            DataSet ds = _rqstbl.getDropDownValues(selectQuery, table, condition);
            chkname.DataSource     = ds.Tables[0];
            chkname.DataValueField = ds.Tables[0].Columns[0].ToString();
            chkname.DataTextField  = ds.Tables[0].Columns[1].ToString();
            chkname.DataBind();
        }
        catch (Exception ex)
        {
            throw;
        }
    }