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(); }
        }