public void bindDeptgrid(long ID)
        {
            DataTable     dt      = new DataTable();
            DataSet       ds      = new DataSet();
            CustomProfile profile = CustomProfile.GetProfile();

            BrilliantWMS.CompanySetupService.iCompanySetupClient company = new BrilliantWMS.CompanySetupService.iCompanySetupClient();
            try
            {
                // ds = company.GetDepartmentListforgrid(ID, profile.DBConnection._constr);
                ds = company.GetDeptListWithSLA(ID, profile.DBConnection._constr);
                dt = ds.Tables[0];
                if (dt.Rows.Count > 0)
                {
                    Grid1.DataSource = ds.Tables[0];
                    Grid1.DataBind();
                }
                else
                {
                    Grid1.DataSource = null;
                    Grid1.DataBind();
                }
            }
            catch { }
            finally
            {
                company.Close();
            }
        }
        protected void BindContactList(long CompanyID)
        {
            DataTable     dt      = new DataTable();
            DataSet       ds      = new DataSet();
            CustomProfile profile = CustomProfile.GetProfile();

            BrilliantWMS.CompanySetupService.iCompanySetupClient CompanyClient = new BrilliantWMS.CompanySetupService.iCompanySetupClient();

            ds = CompanyClient.GetContactPersonLocList(CompanyID, profile.DBConnection._constr);
            dt = ds.Tables[0];
            if (dt.Rows.Count > 0)
            {
                gvContactPerson.DataSource = ds.Tables[0];
                gvContactPerson.DataBind();
            }
            else
            {
                gvContactPerson.DataSource = null;
                gvContactPerson.DataBind();
            }

            //CustomProfile profile = CustomProfile.GetProfile();
            //List<tContactPersonDetail> ConPerLst = new List<tContactPersonDetail>();
            //iUCCommonFilterClient UCCommonFilter = new iUCCommonFilterClient();

            //ConPerLst = UCCommonFilter.GetContactPersonListDeptWise(CompanyID, profile.DBConnection._constr).ToList();

            //gvContactPerson.DataSource = ConPerLst;
            //gvContactPerson.DataBind();
        }
        public void locationDetails(long locationID)
        {
            ddlCountry.SelectedIndex = -1;
            DataTable     dt      = new DataTable();
            DataSet       ds      = new DataSet();
            CustomProfile profile = CustomProfile.GetProfile();

            BrilliantWMS.CompanySetupService.iCompanySetupClient CompanyClient = new BrilliantWMS.CompanySetupService.iCompanySetupClient();
            try
            {
                ds = CompanyClient.GetLocationList(locationID, profile.DBConnection._constr);
                dt = ds.Tables[0];
                if (dt.Rows.Count > 0)
                {
                    ddlcompany.SelectedValue = dt.Rows[0]["CompanyID"].ToString();
                    hdnSelectedCompany.Value = dt.Rows[0]["CompanyID"].ToString();
                    //getDepartment(long.Parse(dt.Rows[0]["CompanyID"].ToString()));
                    // ddldept.SelectedValue = dt.Rows[0]["deptid"].ToString();

                    txtlocationName.Text = dt.Rows[0]["LocationName"].ToString();

                    // hdnSelectedDepartment.Value = dt.Rows[0]["deptid"].ToString();
                    txtlocation.Text  = dt.Rows[0]["LocationCode"].ToString();
                    txtCAddress1.Text = dt.Rows[0]["AddressLine1"].ToString();
                    txtAddress2.Text  = dt.Rows[0]["AddressLine2"].ToString();
                    txtZipCode.Text   = dt.Rows[0]["zipcode"].ToString();
                    txtCity.Text      = dt.Rows[0]["City"].ToString();
                    txtLandMark.Text  = dt.Rows[0]["landmark"].ToString();
                    txtFax.Text       = dt.Rows[0]["FaxNo"].ToString();
                    txtname.Text      = dt.Rows[0]["ContactName"].ToString();
                    txtemailid.Text   = dt.Rows[0]["ContactEmail"].ToString();
                    txtphoneno.Text   = dt.Rows[0]["MobileNo"].ToString();
                    string country = dt.Rows[0]["County"].ToString();
                    string State   = dt.Rows[0]["State"].ToString();
                    hdnSearchContactName1.Value = dt.Rows[0]["ContactName"].ToString();
                    hdnSearchContactID1.Value   = dt.Rows[0]["ShippingID"].ToString();
                    hdnSearchConEmail.Value     = dt.Rows[0]["ContactEmail"].ToString();
                    hdnSearchConMobNo.Value     = dt.Rows[0]["MobileNo"].ToString();
                    if (dt.Rows[0]["Active"].ToString() == "N")
                    {
                        rbtnActiveNo.Checked  = true;
                        rbtnActiveYes.Checked = false;
                    }
                    hdnCountry.Value = country;
                    hdnState.Value   = State;
                    Page.ClientScript.RegisterStartupScript(GetType(), "fillCountry" + sessionID, "setCountry('" + country + "','" + State + "');", true);
                }
            }
            catch (System.Exception ex)
            {
                Login.Profile.ErrorHandling(ex, this, "Location Master", "locationDetails");
            }
            finally
            {
                CompanyClient.Close();
            }
        }
        public void getLocationList()
        {
            DataTable     dt      = new DataTable();
            DataSet       ds      = new DataSet();
            CustomProfile profile = CustomProfile.GetProfile();

            BrilliantWMS.CompanySetupService.iCompanySetupClient CompanyClient = new BrilliantWMS.CompanySetupService.iCompanySetupClient();
            long LocID = 0;

            ds = CompanyClient.GetLocationList(LocID, profile.DBConnection._constr);
            dt = ds.Tables[0];
            if (dt.Rows.Count > 0)
            {
                Gvlocation.DataSource = ds.Tables[0];
                Gvlocation.DataBind();
            }
            else
            {
                Gvlocation.DataSource = null;
                Gvlocation.DataBind();
            }
        }
        protected void pageSave(Object sender, BrilliantWMS.ToolbarService.iUCToolbarClient e)
        {
            CustomProfile profile = CustomProfile.GetProfile();

            BrilliantWMS.CompanySetupService.iCompanySetupClient CompanyClient = new BrilliantWMS.CompanySetupService.iCompanySetupClient();
            try
            {
                long locationid = 0;
                long companyid  = long.Parse(hdnSelectedCompany.Value);
                long deptid     = 0;
                locationid = long.Parse(hdnselectedLocation.Value);
                string hdnstate     = hdnmodestate.Value;
                string locationCode = txtlocation.Text;
                string address1     = txtCAddress1.Text;
                string address2     = txtAddress2.Text;
                string city         = txtCity.Text;
                string zipcode      = txtZipCode.Text;
                string landmark     = txtLandMark.Text;
                string faxno        = txtFax.Text;
                //string contactName = txtname.Text;
                string contactName = hdnSearchContactName1.Value;
                // string email = txtemailid.Text;
                string email        = hdnSearchConEmail.Value;
                string Locationname = txtlocationName.Text;
                long   ContactID    = long.Parse(hdnSearchContactID1.Value);
                long   MobileNo     = 0;
                if (hdnSearchConMobNo.Value != "")
                {
                    MobileNo = long.Parse(hdnSearchConMobNo.Value);
                }
                string Mobilecont = txtphoneno.Text;
                string Country    = hdnCountry.Value;
                string State      = hdnState.Value;
                string userid     = profile.Personal.UserID.ToString();
                string active     = "N";
                if (rbtnActiveYes.Checked == true)
                {
                    active = "Y";
                }

                if (hdnstate == "AddNew")
                {
                    //long ContactID = CompanyClient.SaveLocContactInContact("Contact", companyid, 0, 1, contactName, email, Mobilecont, 4, "Y", userid, DateTime.Now, companyid, profile.DBConnection._constr);
                    CompanyClient.SaveEditLocation(locationid, companyid, deptid, locationCode, address1, address2, Country, State, city, zipcode, landmark, faxno, active, contactName, email, Locationname, MobileNo, userid, DateTime.Now, hdnstate, ContactID, profile.DBConnection._constr);
                    WebMsgBox.MsgBox.Show("Record Saved successfully");
                }
                else
                {
                    long contactIdUpdate = CompanyClient.GetContactIdasShippingId(locationid, profile.DBConnection._constr);

                    if (active == "N")
                    {
                        int totaluser = CompanyClient.CheckLocationIDForAssignedUser(locationid, profile.DBConnection._constr);
                        if (totaluser == 1)
                        {
                            WebMsgBox.MsgBox.Show("Location is assigned for user Please remove the location for that user");
                            // rbtnActiveNo.Text = "";
                            rbtnActiveNo.Checked  = false;
                            rbtnActiveYes.Checked = true;
                        }
                        else
                        {
                            // CompanyClient.UpdateContacttableDetail(contactName, email, Mobilecont, contactIdUpdate, profile.DBConnection._constr);
                            CompanyClient.UpdateLocationDetails(locationid, companyid, deptid, locationCode, address1, address2, Country, State, city, zipcode, landmark, faxno, active, contactName, email, MobileNo, userid, DateTime.Now, hdnstate, Locationname, ContactID, profile.DBConnection._constr);
                            WebMsgBox.MsgBox.Show("Record Updated successfully");
                        }
                    }
                    else
                    {
                        // CompanyClient.UpdateContacttableDetail(contactName, email, Mobilecont, contactIdUpdate, profile.DBConnection._constr);
                        CompanyClient.UpdateLocationDetails(locationid, companyid, deptid, locationCode, address1, address2, Country, State, city, zipcode, landmark, faxno, active, contactName, email, MobileNo, userid, DateTime.Now, hdnstate, Locationname, ContactID, profile.DBConnection._constr);
                        WebMsgBox.MsgBox.Show("Record Updated successfully");
                    }
                }

                clr();
                getLocationList();
                ActiveTab("Load");
            }
            catch (System.Exception ex)
            {
                Login.Profile.ErrorHandling(ex, this, "Location Master", "pageSave");
            }
            finally
            {
                CompanyClient.Close();
            }
        }