public static void WMUpdRequestPartPrice(object objRequest, int ProdID)
        {
            iPartRequestClient objService = new iPartRequestClient();

            try
            {
                Dictionary <string, object> dictionary = new Dictionary <string, object>();
                dictionary = (Dictionary <string, object>)objRequest;
                CustomProfile profile = CustomProfile.GetProfile();
                string        uom     = objService.GetUOMName(Convert.ToInt64(dictionary["UOMID"]), profile.DBConnection._constr);
                POR_SP_GetPartDetail_ForRequest_Result PartRequest = new POR_SP_GetPartDetail_ForRequest_Result();
                PartRequest.Sequence   = Convert.ToInt64(dictionary["Sequence"]);
                PartRequest.RequestQty = Convert.ToDecimal(dictionary["RequestQty"]); PartRequest.UOM = uom;
                PartRequest.UOMID      = Convert.ToInt64(dictionary["UOMID"]);
                PartRequest.Total      = Convert.ToDecimal(dictionary["Total"]);
                PartRequest.Price      = Convert.ToDecimal(dictionary["Price"]);
                // PartRequest.IsPriceChange = Convert.ToInt16(dictionary["IsPriceChange"]);
                decimal price            = Convert.ToDecimal(dictionary["Price"]);
                int     ISPriceChangedYN = objService.IsPriceChanged(ProdID, price, profile.DBConnection._constr);
                if (ISPriceChangedYN == 0)
                {
                    PartRequest.IsPriceChange = 0;
                }
                else
                {
                    PartRequest.IsPriceChange = 1;
                }
                objService.UpdatePartRequest_TempData12(HttpContext.Current.Session.SessionID, ObjectName, profile.Personal.UserID.ToString(), PartRequest, profile.DBConnection._constr);
            }
            catch (System.Exception ex) { Login.Profile.ErrorHandling(ex, "PartRequestEntry.aspx", "WMUpdRequestPart"); }
            finally { objService.Close(); }
        }
Beispiel #2
0
        protected void GetRequestHeadByRequestID()
        {
            iPartRequestClient objService = new iPartRequestClient();

            try
            {
                CustomProfile profile = CustomProfile.GetProfile();
                POR_SP_GetRequestByRequestIDs_Result RequestHead = new POR_SP_GetRequestByRequestIDs_Result();
                RequestHead = objService.GetRequestSummayByRequestIDs(Session["PORRequestID"].ToString(), profile.DBConnection._constr).FirstOrDefault();
                if (RequestHead != null)
                {
                    lblRequestNo.Text     = RequestHead.PRH_ID.ToString();
                    lblRequestNo2.Text    = RequestHead.PRH_ID.ToString();
                    hdnRequestID.Value    = RequestHead.PRH_ID.ToString();
                    lblRequestDate.Text   = RequestHead.RequestDate.Value.ToString("dd-MMM-yyyy");
                    lblRequestStatus.Text = RequestHead.RequestStatus.ToString();
                    lblSites.Text         = RequestHead.SiteName.ToString();
                    hdnSiteID.Value       = RequestHead.SiteID.ToString();
                    lblRequestType.Text   = RequestHead.RequestType.ToString();
                    lblRequestedBy.Text   = RequestHead.RequestByUserName.ToString();
                    GetReceiptHistoryByRequestID();
                }
            }
            catch { }
            finally { objService.Close(); }
        }
Beispiel #3
0
        public static string WMSaveApproval(long RequestID, string ApprovalStatus, long APL, string ApprovalRemark, string InvoiceNo)
        {
            iPartRequestClient objService = new iPartRequestClient();
            string             result     = "";

            try
            {
                CustomProfile profile = CustomProfile.GetProfile();

                if (ApprovalStatus == "3")
                {
                    objService.UpdatetApprovalTransAfterApproval(APL, RequestID, 3, ApprovalRemark, profile.Personal.UserID, InvoiceNo, profile.DBConnection._constr);
                    result = "true";
                }
                else if (ApprovalStatus == "4")
                {
                    objService.UpdatetApprovalTransAfterReject(APL, RequestID, 4, ApprovalRemark, profile.Personal.UserID, profile.DBConnection._constr);
                    result = "true";
                }
                else if (ApprovalStatus == "24")
                {
                    objService.UpdatetApprovalTransAfterApproval(0, RequestID, 24, ApprovalRemark, profile.Personal.UserID, "0", profile.DBConnection._constr);
                    result = "truerev";
                }
            }
            catch { }
            finally
            { objService.Close(); }
            return(result);
        }
        protected void FillGVRequest(string FillBy, string Invoker)
        {
            iPartRequestClient objServie = new iPartRequestClient();

            try
            {
                CustomProfile profile = CustomProfile.GetProfile();
                GVRequest.DataSource = null;
                GVRequest.DataBind();
                //New Added By Suresh for GWC

                string UserType = profile.Personal.UserType.ToString();

                //New Added By Suresh for GWC
                if (FillBy == "UserID")
                {
                    if (Invoker == "Request")
                    {
                        if (UserType == "User" || UserType == "Requester" || UserType == "Requestor")
                        {
                            GVRequest.DataSource = objServie.GetRequestSummayOfUser(profile.Personal.UserID, profile.DBConnection._constr);
                        }
                        else
                        {
                            GVRequest.DataSource = objServie.GetRequestSummayByUserID(profile.Personal.UserID, profile.DBConnection._constr);
                        }
                        GVRequest.Columns[12].Visible = false; GVRequest.AllowMultiRecordSelection = true; GVRequest.AllowRecordSelection = true;
                    }
                    else if (Invoker == "Issue")
                    {
                        if (UserType == "User" || UserType == "Requester" || UserType == "Requestor")
                        {
                            GVRequest.DataSource = objServie.GetRequestSummayOfUserIssue(profile.Personal.UserID, profile.DBConnection._constr);
                        }
                        else
                        {
                            GVRequest.DataSource = objServie.GetRequestSummayByUserIDIssue(profile.Personal.UserID, profile.DBConnection._constr);
                        }
                        GVRequest.Columns[12].Visible = true; GVRequest.AllowMultiRecordSelection = true; GVRequest.AllowRecordSelection = true;
                    }
                }
                else if (FillBy == "SiteIDs")
                {
                    GVRequest.DataSource = objServie.GetRequestSummayBySiteIDs(Session["SiteIDs"].ToString(), profile.DBConnection._constr);
                }
                GVRequest.DataBind();
            }
            catch { }
            finally { objServie.Close(); }
        }
        public static List <POR_SP_GetRequestByRequestIDs_Result> WMGetRequestHead(string RequestIDs)
        {
            iPartRequestClient objService = new iPartRequestClient();
            List <POR_SP_GetRequestByRequestIDs_Result> RequestHead = new List <POR_SP_GetRequestByRequestIDs_Result>();

            try
            {
                CustomProfile profile = CustomProfile.GetProfile();
                RequestHead = objService.GetRequestSummayByRequestIDs(RequestIDs, profile.DBConnection._constr).ToList();
            }
            catch { }
            finally { objService.Close(); }
            return(RequestHead);
        }
        public static decimal WMGetTotalQty()
        {
            iPartRequestClient objService = new iPartRequestClient();
            decimal            tot        = 0;

            try
            {
                CustomProfile profile = CustomProfile.GetProfile();
                POR_SP_GetPartDetail_ForRequest_Result PartRequest = new POR_SP_GetPartDetail_ForRequest_Result();
                tot = objService.GetTotalQTYFromTempData(HttpContext.Current.Session.SessionID, ObjectName, profile.Personal.UserID.ToString(), profile.DBConnection._constr);
            }
            catch (System.Exception ex) { Login.Profile.ErrorHandling(ex, "PartRequestEntry.aspx", "WMGetTotalQty"); }
            finally { objService.Close(); }
            return(tot);
        }
        public static void WMRemovePartFromRequest(Int32 Sequence)
        {
            iPartRequestClient objService = new iPartRequestClient();

            try
            {
                Dictionary <string, object> dictionary = new Dictionary <string, object>();
                CustomProfile profile = CustomProfile.GetProfile();
                objService.RemovePartFromRequest_TempData(HttpContext.Current.Session.SessionID, profile.Personal.UserID.ToString(), ObjectName, Sequence, profile.DBConnection._constr);
            }
            catch (System.Exception ex)
            {
                Login.Profile.ErrorHandling(ex, "Request Template", "WMRemovePartFromRequest");
            }
            finally { objService.Close(); }
        }
        protected void Grid1_OnRebind(object sender, EventArgs e)
        {
            iPartRequestClient objService = new iPartRequestClient();

            try
            {
                Grid1.DataSource = null;
                Grid1.DataBind();
                CustomProfile profile = CustomProfile.GetProfile();
                HiddenField   hdn     = (HiddenField)UCProductSearch1.FindControl("hdnProductSearchSelectedRec");
                List <POR_SP_GetPartDetail_ForRequest_Result> RequestPartList = new List <POR_SP_GetPartDetail_ForRequest_Result>();
                if (hdn.Value == "")
                {
                    RequestPartList = objService.GetExistingTempDataBySessionIDObjectName(Session.SessionID, profile.Personal.UserID.ToString(), ObjectName, profile.DBConnection._constr).ToList();
                }
                else if (hdn.Value != "")
                {
                    RequestPartList = objService.AddPartIntoRequest_TempData(hdn.Value, Session.SessionID, profile.Personal.UserID.ToString(), ObjectName, 0, profile.DBConnection._constr).ToList();
                }

                ////Add by Suresh
                //if (hdnprodID.Value != "")
                //{
                //    RequestPartList = objService.AddPartIntoRequest_TempData(hdnprodID.Value, Session.SessionID, profile.Personal.UserID.ToString(), ObjectName, Convert.ToInt32(ddlSites.SelectedItem.Value), profile.DBConnection._constr).ToList();
                //    hdnprodID.Value = "";
                //}

                if (hdnChngDept.Value == "0x00x0")
                {
                    objService.ClearTempDataFromDBNEW(HttpContext.Current.Session.SessionID, profile.Personal.UserID.ToString(), ObjectName, profile.DBConnection._constr);
                    RequestPartList = null;
                }
                hdnChngDept.Value = "";
                var chngdpt = "1x1";
                hdnChngDept.Value = chngdpt;

                Grid1.DataSource = RequestPartList;
                Grid1.DataBind();
            }
            catch (System.Exception ex)
            {
                Login.Profile.ErrorHandling(ex, this, "Request Template", "Grid1_OnRebind");
            }
            finally { objService.Close(); }
        }
        protected void Grid1_RowCommand(object sender, Obout.Grid.GridRowEventArgs e)
        {
            iPartRequestClient objService = new iPartRequestClient();
            CustomProfile      profile    = CustomProfile.GetProfile();

            try
            {
                Obout.Grid.GridDataControlFieldCell cell = e.Row.Cells[6] as Obout.Grid.GridDataControlFieldCell;
                DropDownList ddl = cell.FindControl("ddlUOM") as DropDownList;

                ddl.Attributes.Add("onchange", "javascript:GetIndex('" + ddl.SelectedIndex + "'," + e.Row.RowIndex + ")");
            }
            catch (System.Exception ex)
            {
                Login.Profile.ErrorHandling(ex, this, "Request Template", "Grid1_RowCommand");
            }
            finally { objService.Close(); }
        }
        public static void WMUpdateRequestQty(object objRequest)
        {
            iPartRequestClient objService = new iPartRequestClient();

            try
            {
                Dictionary <string, object> dictionary = new Dictionary <string, object>();
                dictionary = (Dictionary <string, object>)objRequest;
                CustomProfile profile = CustomProfile.GetProfile();

                POR_SP_GetPartDetail_ForRequest_Result PartRequest = new POR_SP_GetPartDetail_ForRequest_Result();
                PartRequest.Sequence   = Convert.ToInt64(dictionary["Sequence"]);
                PartRequest.RequestQty = Convert.ToDecimal(dictionary["RequestQty"]);

                objService.UpdatePartRequest_TempData(HttpContext.Current.Session.SessionID, ObjectName, profile.Personal.UserID.ToString(), PartRequest, profile.DBConnection._constr);
            }
            catch (System.Exception ex)
            {
                Login.Profile.ErrorHandling(ex, "Request Template", "WMUpdateRequestQty");
            }
            finally { objService.Close(); }
        }
        protected void Grid1_OnRowDataBound(object sender, Obout.Grid.GridRowEventArgs e)
        {
            iPartRequestClient objService = new iPartRequestClient();
            CustomProfile      profile    = CustomProfile.GetProfile();

            try
            {
                if (e.Row.RowType == Obout.Grid.GridRowType.DataRow)
                {
                    //Obout.Grid.GridDataControlFieldCell cell = e.Row.Cells[6] as Obout.Grid.GridDataControlFieldCell;
                    //Obout.Grid.GridDataControlFieldCell cell = e.Row.Cells[7] as Obout.Grid.GridDataControlFieldCell;
                    Obout.Grid.GridDataControlFieldCell cell = e.Row.Cells[8] as Obout.Grid.GridDataControlFieldCell;

                    DropDownList ddl    = cell.FindControl("ddlUOM") as DropDownList;
                    HiddenField  hdnUOM = cell.FindControl("hdnMyUOM") as HiddenField;
                    //Label rowQtySpn = e.Row.Cells[9].FindControl("rowQtyTotal") as Label;
                    Label rowQtySpn = e.Row.Cells[10].FindControl("rowQtyTotal") as Label;

                    //TextBox txtUsrQty = e.Row.Cells[6].FindControl("txtUsrQty") as TextBox;
                    TextBox txtUsrQty = e.Row.Cells[7].FindControl("txtUsrQty") as TextBox;

                    int     ProdID = Convert.ToInt32(e.Row.Cells[0].Text);
                    decimal moq    = Convert.ToDecimal(e.Row.Cells[6].Text);

                    TextBox txtUsrPrice   = e.Row.Cells[11].FindControl("txtUsrPrice") as TextBox;
                    Label   rowPriceTotal = e.Row.Cells[12].FindControl("rowPriceTotal") as Label;

                    DataSet dsUOM = new DataSet();
                    dsUOM = objService.GetUOMofSelectedProduct(ProdID, profile.DBConnection._constr);

                    ddl.DataSource     = dsUOM;
                    ddl.DataTextField  = "Description";
                    ddl.DataValueField = "UMOGroup";
                    ddl.DataBind();

                    decimal SelectedQty = 0, SelectedUOM = 0;
                    decimal Price = decimal.Parse(txtUsrPrice.Text.ToString());

                    //ddl.SelectedValue = e.Row.Cells[6].Text;
                    if (hdnTemplateID.Value != "")
                    {
                        long   TemplID     = Convert.ToInt64(hdnTemplateID.Value);
                        string selectedUom = objService.GetSelectedUomTemplate(TemplID, ProdID, profile.DBConnection._constr);
                        ddl.SelectedIndex  = ddl.Items.IndexOf(ddl.Items.FindByValue(selectedUom.ToString()));
                        rowQtySpn.Text     = txtUsrQty.Text;
                        rowPriceTotal.Text = e.Row.Cells[12].Text;
                    }
                    else
                    {
                        ddl.SelectedIndex = 2;

                        SelectedQty = decimal.Parse(dsUOM.Tables[0].Rows[2]["Quantity"].ToString());
                        SelectedUOM = decimal.Parse(dsUOM.Tables[0].Rows[2]["UOMID"].ToString());
                        decimal rowQty = decimal.Parse(txtUsrQty.Text.ToString());
                        decimal UsrQty = SelectedQty * rowQty;

                        hdnSelectedQty.Value = SelectedQty.ToString();
                        rowQtySpn.Text       = UsrQty.ToString();
                    }

                    ddl.Attributes.Add("onchange", "javascript:GetIndex(this,'" + hdnUOM.ClientID.ToString() + "','" + rowQtySpn.ClientID.ToString() + "','" + txtUsrQty.ClientID.ToString() + "'," + e.Row.RowIndex + "," + Price + ",'" + rowPriceTotal.ClientID.ToString() + "'," + moq + ")");

                    txtUsrQty.Attributes.Add("onblur", "javascript:GetIndexQty(this," + SelectedQty + "," + SelectedUOM + ",'" + rowQtySpn.ClientID.ToString() + "','" + txtUsrQty.ClientID.ToString() + "'," + e.Row.RowIndex + "," + Price + ",'" + rowPriceTotal.ClientID.ToString() + "'," + moq + ")");

                    txtUsrPrice.Attributes.Add("onblur", "javascript:GetChangedPrice(this," + SelectedQty + "," + SelectedUOM + ",'" + rowQtySpn.ClientID.ToString() + "','" + txtUsrQty.ClientID.ToString() + "'," + e.Row.RowIndex + ",'" + rowPriceTotal.ClientID.ToString() + "'," + ProdID + ")");
                    //}
                }
            }
            catch (System.Exception ex)
            {
                Login.Profile.ErrorHandling(ex, this, "Request Template", "Grid1_OnRowDataBound");
            }
            finally { objService.Close(); }
        }
        protected void GetTemplateDetails()
        {
            iPartRequestClient   objService = new iPartRequestClient();
            mRequestTemplateHead ReqTmpHead = new mRequestTemplateHead();

            try
            {
                CustomProfile profile = CustomProfile.GetProfile();
                ReqTmpHead = objService.GetTemplateOrderHead(Convert.ToInt64(hdnTemplateID.Value), profile.DBConnection._constr);

                long SiteID = Convert.ToInt64(ReqTmpHead.Department); hdnselectedDept.Value = SiteID.ToString(); Session["DeptID"] = SiteID.ToString();

                iUCCommonFilterClient objCommon = new iUCCommonFilterClient();
                long CompanyID = objCommon.GetCompanyIDFromSiteID(SiteID, profile.DBConnection._constr);

                txtTitle.Text = ReqTmpHead.TemplateTitle.ToString();
                ddlAccessType.SelectedValue = ReqTmpHead.Accesstype.ToString();

                //ddlCompany.SelectedIndex = ddlCompany.Items.IndexOf(ddlCompany.Items.FindByValue(ReqTmpHead.Customer.ToString()));
                //cmp = long.Parse(ReqTmpHead.Customer.ToString());
                List <mCompany> CompanyLst = new List <mCompany>();
                string          UserType   = profile.Personal.UserType.ToString();
                long            UID        = profile.Personal.UserID;

                if (UserType == "Admin")
                {
                    //  CompanyLst = objService.GetCompanyName(profile.DBConnection._constr).ToList();
                    // CompanyLst = objService.GetUserCompanyName(UID, profile.DBConnection._constr).ToList();

                    CompanyLst = objCommon.GetUserCompanyNameNEW(UID, profile.DBConnection._constr).ToList();
                }
                else if (UserType == "User" || UserType == "Requester And Approver" || UserType == "Requester" || profile.Personal.UserType == "Requestor" || profile.Personal.UserType == "Requestor And Approver")
                {
                    CompanyLst = objCommon.GetUserCompanyName(UID, profile.DBConnection._constr).ToList();
                }
                else
                {
                    CompanyLst = objCommon.GetCompanyName(profile.DBConnection._constr).ToList();
                }
                ddlCompany.DataSource = CompanyLst;
                ddlCompany.DataBind();

                ddlCompany.SelectedIndex = ddlCompany.Items.IndexOf(ddlCompany.Items.FindByValue(CompanyID.ToString())); //ddlCompany.Items.IndexOf(ddlCompany.Items.FindByValue(ReqTmpHead.Customer.ToString()));
                cmp = CompanyID;

                int Cmpny = int.Parse(CompanyID.ToString());  //Convert.ToInt16(ReqTmpHead.Customer.ToString());
                ddlSites.DataSource = WMGetDept(Cmpny);
                ddlSites.DataBind();
                ddlSites.SelectedIndex = ddlSites.Items.IndexOf(ddlSites.Items.FindByValue(ReqTmpHead.Department.ToString()));
                dpt = long.Parse(ReqTmpHead.Department.ToString());

                txtRemark.Text = ReqTmpHead.Remark.ToString();

                //ddlAddress.DataSource = WMGetDeptAddress(CompanyID); //WMGetDeptAddress(SiteID);
                //ddlAddress.DataBind();
                //ddlAddress.SelectedIndex = ddlAddress.Items.IndexOf(ddlAddress.Items.FindByValue(ReqTmpHead.Address.ToString()));
                //adrs = long.Parse(ReqTmpHead.Address.ToString());

                //ddlContact1.DataSource = WMGetContactPersonLst(CompanyID); //WMGetContactPersonLst(SiteID);
                //ddlContact1.DataBind();
                //ddlContact1.SelectedIndex = ddlContact1.Items.IndexOf(ddlContact1.Items.FindByValue(ReqTmpHead.Contact1.ToString()));
                //c1 = long.Parse(ReqTmpHead.Contact1.ToString());
                ////ddlContact2.DataSource = WMGetContactPerson2Lst(Convert.ToInt64(ReqTmpHead.Department), Convert.ToInt64(ddlContact1.SelectedIndex));
                //ddlContact2.DataSource = WMGetContactPerson2Lst(CompanyID, Convert.ToInt64(ddlContact1.SelectedIndex));
                //ddlContact2.DataBind();
                //ddlContact2.SelectedIndex = ddlContact2.Items.IndexOf(ddlContact2.Items.FindByValue(ReqTmpHead.Contact2.ToString()));
                //c2 = long.Parse(ReqTmpHead.Contact2.ToString());

                //lblAddress.Text = ddlAddress.SelectedItem.ToString();

                DataSet dsTemplatePartLst = new DataSet();
                dsTemplatePartLst = objService.GetTemplatePartLstByTemplateID(Convert.ToInt64(hdnTemplateID.Value), profile.DBConnection._constr);
                List <POR_SP_GetPartDetail_ForRequest_Result> TemplatePartList = new List <POR_SP_GetPartDetail_ForRequest_Result>();
                if (dsTemplatePartLst.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i <= dsTemplatePartLst.Tables[0].Rows.Count - 1; i++)
                    {
                        TemplatePartList = objService.AddPartIntoRequest_TempData(dsTemplatePartLst.Tables[0].Rows[i]["PrdID"].ToString(), Session.SessionID, profile.Personal.UserID.ToString(), ObjectName, SiteID, profile.DBConnection._constr).ToList();
                        string uom = objService.GetUOMName(Convert.ToInt64(dsTemplatePartLst.Tables[0].Rows[i]["UOMID"].ToString()), profile.DBConnection._constr);
                        POR_SP_GetPartDetail_ForRequest_Result PartRequest = new POR_SP_GetPartDetail_ForRequest_Result();
                        PartRequest.Sequence      = i + 1;
                        PartRequest.RequestQty    = Convert.ToDecimal(dsTemplatePartLst.Tables[0].Rows[i]["Qty"].ToString()); // Convert.ToDecimal(dictionary["RequestQty"]);
                        PartRequest.Price         = Convert.ToDecimal(dsTemplatePartLst.Tables[0].Rows[i]["Price"].ToString());
                        PartRequest.Total         = Convert.ToDecimal(dsTemplatePartLst.Tables[0].Rows[i]["Total"].ToString());
                        PartRequest.IsPriceChange = Convert.ToInt16(dsTemplatePartLst.Tables[0].Rows[i]["IsPriceChange"].ToString());
                        PartRequest.UOMID         = Convert.ToInt64(dsTemplatePartLst.Tables[0].Rows[i]["UOMID"].ToString());
                        PartRequest.UOM           = uom;

                        objService.UpdatePartRequest_TempData12(HttpContext.Current.Session.SessionID, ObjectName, profile.Personal.UserID.ToString(), PartRequest, profile.DBConnection._constr);
                        // objService.UpdatePartRequest_TempData(HttpContext.Current.Session.SessionID, ObjectName, profile.Personal.UserID.ToString(), PartRequest, profile.DBConnection._constr);

                        TemplatePartList = objService.GetExistingTempDataBySessionIDObjectName(Session.SessionID, profile.Personal.UserID.ToString(), ObjectName, profile.DBConnection._constr).ToList();
                    }
                }

                Grid1.DataSource = TemplatePartList;
                Grid1.DataBind();
            }
            catch (System.Exception ex)
            {
                Login.Profile.ErrorHandling(ex, this, "Request Template", "GetTemplateDetails");
            }
            finally { objService.Close(); }
        }
        protected void pageSave(object sender, BrilliantWMS.ToolbarService.iUCToolbarClient e)
        {
            iPartRequestClient objService = new iPartRequestClient();

            try
            {
                CustomProfile        profile     = CustomProfile.GetProfile();
                mRequestTemplateHead ReqTempHead = new mRequestTemplateHead();

                int cnt;
                cnt = objService.GridRowCount(Session.SessionID, ObjectName, profile.Personal.UserID.ToString(), profile.DBConnection._constr);

                if (cnt == 0)
                {
                    WebMsgBox.MsgBox.Show("Add atleast one part into the Request Part List");
                }
                else
                {
                    List <POR_SP_GetPartDetail_ForRequest_Result> GetGridRowsTemplate = new List <POR_SP_GetPartDetail_ForRequest_Result>();
                    GetGridRowsTemplate = objService.GridRowsTemplate(Session.SessionID, ObjectName, profile.Personal.UserID.ToString(), profile.DBConnection._constr).ToList();
                    //var ReqQty = GetGridRowsTemplate.Where(r => r.RequestQty == 0).ToList();

                    //long RQty = Convert.ToInt64(ReqQty.Count);
                    //if (RQty >=1)
                    //{
                    //    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "showAlert('One or more request quantity is zero','Error','#')", true);

                    //}
                    //else
                    //{

                    if (hdnTemplateID.Value == "")
                    {
                        ReqTempHead.CreatedBy   = profile.Personal.UserID;
                        ReqTempHead.CreatedDate = DateTime.Now;
                    }
                    else
                    {
                        ReqTempHead             = objService.GetTemplateOrderHead(Convert.ToInt64(hdnTemplateID.Value), profile.DBConnection._constr);
                        ReqTempHead.CreatedBy   = ReqTempHead.CreatedBy;
                        ReqTempHead.CreatedDate = ReqTempHead.CreatedDate;

                        ReqTempHead.ModifiedBy   = profile.Personal.UserID;
                        ReqTempHead.ModifiedDate = DateTime.Now;
                        ReqTempHead.ID           = Convert.ToInt64(hdnTemplateID.Value);
                    }

                    ReqTempHead.TemplateTitle = txtTitle.Text;
                    ReqTempHead.Accesstype    = ddlAccessType.SelectedValue.ToString();

                    if (hdnselectedDept.Value == "")
                    {
                        ReqTempHead.Department = dpt;
                    }
                    else
                    {
                        ReqTempHead.Department = Convert.ToInt64(hdnselectedDept.Value);
                    }

                    if (hdnselectedCompany.Value == "")
                    {
                        ReqTempHead.Customer = cmp;
                    }
                    else
                    {
                        ReqTempHead.Customer = Convert.ToInt64(hdnselectedCompany.Value);
                    }
                    ReqTempHead.Active = "Yes";

                    ReqTempHead.Remark = txtRemark.Text;
                    if (hdnSelAddress.Value == "")
                    {
                        ReqTempHead.Address = adrs;
                    }
                    else
                    {
                        ReqTempHead.Address = Convert.ToInt64(hdnSelAddress.Value);
                    }
                    if (hdnselectedCont1.Value == "")
                    {
                        ReqTempHead.Contact1 = c1;
                    }
                    else
                    {
                        ReqTempHead.Contact1 = Convert.ToInt64(hdnselectedCont1.Value);
                    }
                    if (hdnselectedCont2.Value == "")
                    {
                        ReqTempHead.Contact2 = c2;
                    }
                    else
                    {
                        ReqTempHead.Contact2 = Convert.ToInt64(hdnselectedCont2.Value);
                    }

                    long RequestTemplateID = objService.InsertIntomRequestTemplateHead(ReqTempHead, profile.DBConnection._constr);
                    if (RequestTemplateID > 0)
                    {
                        objService.FinalSavemRequestTemplateDetailTemplate(HttpContext.Current.Session.SessionID, ObjectName, RequestTemplateID, profile.Personal.UserID.ToString(), profile.DBConnection._constr);
                        WebMsgBox.MsgBox.Show("Template Saved Successfully");
                        clearfields();
                        //tbTemplateLst.Visible = true;
                        //tbTemplateDetail.Visible = false;
                        //tabContainerReqTemplate.ActiveTabIndex = 0;
                        //GetTemplateList();
                        //Response.Redirect("../PowerOnRent/RequestTemplate.aspx");
                    }
                    //}
                }
                //}
            }
            catch (System.Exception ex)
            {
                Login.Profile.ErrorHandling(ex, this, "Request Template", "pageSave");
            }
            finally { objService.Close(); }
        }
        protected void DisplayRequestData()
        {
            iPartRequestClient objService      = new iPartRequestClient();
            iPartIssueClient   objServiceIssue = new iPartIssueClient();
            POR_SP_GetRequestByRequestIDs_Result RequestHead = new POR_SP_GetRequestByRequestIDs_Result();

            try
            {
                CustomProfile profile = CustomProfile.GetProfile();
                RequestHead           = objService.GetRequestSummayByRequestIDs(Session["PORRequestID"].ToString(), profile.DBConnection._constr).FirstOrDefault();
                hdnRequestID.Value    = RequestHead.PRH_ID.ToString();
                hdnSiteID.Value       = RequestHead.SiteID.ToString();
                lblRequestNo2.Text    = RequestHead.PRH_ID.ToString();
                lblRequestNo3.Text    = RequestHead.PRH_ID.ToString();
                lblSites.Text         = RequestHead.SiteName;
                lblRequestStatus.Text = RequestHead.RequestStatus;
                lblRequestDate.Text   = RequestHead.RequestDate.Value.ToString("dd-MMM-yyyy");
                lblRequestType.Text   = RequestHead.RequestType;
                lblRequestedBy.Text   = RequestHead.RequestByUserName;
                if (WMGetIssueSummaryByRequestID() == 0)
                {
                    FillGrid1ByRequestID(Convert.ToInt64(Session["PORRequestID"].ToString()));
                    HttpContext.Current.Session["PORstate"]   = "Add";
                    HttpContext.Current.Session["PORIssueID"] = "0";
                    lblIssueNo.Text = "Generate when Save";

                    ddlStatus.DataSource = WMFillStatus();
                    ddlStatus.DataBind();
                    if (ddlStatus.Items.Count > 1)
                    {
                        ddlStatus.SelectedIndex = 1;
                    }
                    FillUserList(1);
                    ddlIssuedBy.SelectedIndex = ddlIssuedBy.Items.IndexOf(ddlIssuedBy.Items.FindByValue(profile.Personal.UserID.ToString()));

                    UC_IssueDate.Date       = DateTime.Now;
                    UC_ShippingDate.Date    = DateTime.Now;
                    UC_ExpDeliveryDate.Date = DateTime.Now;
                }
                else
                {
                    FillUserList(1);
                    ddlIssuedBy.SelectedIndex = ddlIssuedBy.Items.IndexOf(ddlIssuedBy.Items.FindByValue(profile.Personal.UserID.ToString()));
                    //add by suresh
                    ddlStatus.DataSource = WMFillStatus();
                    ddlStatus.DataBind();

                    UC_IssueDate.Date       = DateTime.Now;
                    UC_ShippingDate.Date    = DateTime.Now;
                    UC_ExpDeliveryDate.Date = DateTime.Now;
                }

                bool AddNewAccess = false;
                AddNewAccess = objServiceIssue.CheckPendingIssueListToDecideAddNewAccess(RequestHead.PRH_ID, profile.DBConnection._constr);
                if (Toolbar1.GetUserRightsByObjectName("MaterialIssue", "", "").Add == true)
                {
                    if (AddNewAccess == false)
                    {
                        Toolbar1.SetAddNewRight(false, "Here is no pending issue against current request", "#");
                    }
                }
            }
            catch { }
            finally { objService.Close(); }
        }
        public void GetDefaultConsumptionfromRequestHead()
        {
            iPartRequestClient     objRequestService     = new iPartRequestClient();
            iPartIssueClient       objIssueService       = new iPartIssueClient();
            iPartReceiptClient     objReceiptService     = new iPartReceiptClient();
            iPartConsumptionClient objConsumptionService = new iPartConsumptionClient();

            try
            {
                HttpContext.Current.Session["PORConsumptionID"] = "0";
                CustomProfile profile = CustomProfile.GetProfile();
                if (Session["PORReceiptID"] != null)
                {
                    if (Session["PORReceiptID"].ToString() != "0")
                    {
                        PORtGRNHead         ReceiptHead = new PORtGRNHead();
                        PORtMINHead         IssueHead   = new PORtMINHead();
                        PORtPartRequestHead RequestHead = new PORtPartRequestHead();
                        ReceiptHead = objReceiptService.GetReceiptHeadByReceiptID(Convert.ToInt64(Session["PORReceiptID"].ToString()), profile.DBConnection._constr);
                        if (ReceiptHead != null)
                        {
                            IssueHead = objIssueService.GetIssueHeadByIssueID(Convert.ToInt64(ReceiptHead.ReferenceID), profile.DBConnection._constr);
                        }
                        if (IssueHead != null)
                        {
                            RequestHead = objRequestService.GetRequestHeadByRequestID(Convert.ToInt64(IssueHead.PRH_ID), profile.DBConnection._constr);
                        }

                        if (RequestHead != null)
                        {
                            ddlSites.SelectedIndex  = ddlSites.Items.IndexOf(ddlSites.Items.FindByValue(RequestHead.SiteID.ToString()));
                            UC_DateConsumption.Date = DateTime.Now;
                            ddlStatus.SelectedIndex = 1;

                            ddlConsumedBy.DataSource = null;
                            ddlConsumedBy.DataBind();
                            ddlConsumedBy.DataSource = WMFillUserList(Convert.ToInt64(RequestHead.SiteID));
                            ddlConsumedBy.DataBind();
                            ddlConsumedBy.SelectedIndex = ddlConsumedBy.Items.IndexOf(ddlConsumedBy.Items.FindByValue(profile.Personal.UserID.ToString()));

                            ddlContainer.DataSource = null;
                            ddlContainer.DataBind();

                            ddlContainer.DataSource = WMFillEnginList(Convert.ToInt64(RequestHead.SiteID));
                            ddlContainer.DataBind();
                            ddlContainer.SelectedIndex = ddlContainer.Items.IndexOf(ddlContainer.Items.FindByText(RequestHead.Container.ToString()));

                            lblEngineModel.Text  = RequestHead.EngineModel.ToString();
                            lblEngineSerial.Text = RequestHead.EngineSerial.ToString();

                            txtFailureHours.Text  = RequestHead.FailureHours.ToString();
                            txtFailureCause.Text  = RequestHead.FailureCause.ToString();
                            txtFailureNature.Text = RequestHead.FailureNature.ToString();

                            FillPartDetailByReceiptID(Convert.ToInt64(Session["PORReceiptID"].ToString()));
                        }
                    }
                }
            }
            catch { }
            finally
            {
                objRequestService.Close();
                objIssueService.Close();
                objReceiptService.Close();
            }
        }