예제 #1
0
        protected void BindAddressFromTempData()
        {
            CustomProfile      profile       = CustomProfile.GetProfile();
            iAddressInfoClient AddressClient = new iAddressInfoClient();

            if (hdnbilling.Value == "")
            {
                hdnbilling.Value = "1";
            }
            if (hdnshipping.Value == "")
            {
                hdnshipping.Value = "1";
            }
            GvAddressInfo.DataSource = AddressClient.GetAddressTempData(hdnAddressTargetObject.Value + "_Address", Convert.ToInt64(hdnbilling.Value), Convert.ToInt64(hdnshipping.Value), Session.SessionID, profile.Personal.UserID.ToString(), profile.DBConnection._constr);
            GvAddressInfo.DataBind();
            AddressClient.Close();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Lang"] == "")
            {
                Session["Lang"] = Request.UserLanguages[0];
            }
            loadstring();
            sessionID = Session.SessionID;
            if (hdnbilling.Value == "")
            {
                hdnbilling.Value = "1";
            }
            BillingSeq = hdnbilling.Value;

            if (hdnshipping.Value == "")
            {
                hdnshipping.Value = "1";
            }
            ShippingSeq = hdnshipping.Value;
            if (Session["CompanyID"] != null)
            {
                CustomProfile      profile       = CustomProfile.GetProfile();
                iAddressInfoClient AddressClient = new iAddressInfoClient();
                DataSet            ds            = AddressClient.GridFillAddressByObjectNameReferenceID(long.Parse(Session["CompanyID"].ToString()), profile.DBConnection._constr);
                DataTable          dt            = ds.Tables[0];
                if (dt.Rows.Count > 0)
                {
                    GvAddressInfo.DataSource = ds.Tables[0];
                    GvAddressInfo.DataBind();
                    // btnsave.Visible = false;
                }
                else
                {
                    GvAddressInfo.DataSource = null;
                    GvAddressInfo.DataBind();
                }
            }
            if (IsPostBack)
            {
                //BindAddressFromTempData();
            }
        }
        public void FillAddressByObjectNameReferenceID(string SourceObjectName, long ReferenceID, string TargetObjectName)
        {
            try
            {
                if (hdnAddressTargetObject != null)
                {
                    hdnAddressTargetObject.Value = TargetObjectName;
                }
                CustomProfile      profile       = CustomProfile.GetProfile();
                iAddressInfoClient AddressClient = new iAddressInfoClient();
                List <SP_GetAddressListToBindGrid_Result> Addresslst = new List <SP_GetAddressListToBindGrid_Result>();
                if (sessionID == null)
                {
                    sessionID = Session.SessionID;
                }
                Addresslst = AddressClient.GetAddressByObjectNameReferenceID(SourceObjectName, ReferenceID, TargetObjectName + "_Address", sessionID, profile.Personal.UserID.ToString(), profile.DBConnection._constr).ToList();
                if (GvAddressInfo != null)
                {
                    GvAddressInfo.DataSource = Addresslst;
                    GvAddressInfo.DataBind();

                    if (hdnbilling != null)
                    {
                        hdnbilling.Value = Addresslst.Where(add => add.BillIsChecked == "true").FirstOrDefault() == null ? "1" : Addresslst.Where(add => add.BillIsChecked == "true").FirstOrDefault().Sequence.ToString();
                    }
                    if (hdnshipping != null)
                    {
                        hdnshipping.Value = Addresslst.Where(add => add.ShipIsChecked == "true").FirstOrDefault() == null ? "1" : hdnshipping.Value = Addresslst.Where(add => add.ShipIsChecked == "true").FirstOrDefault().Sequence.ToString();
                    }
                }

                AddressClient.Close();
                // btnsave.Visible = false;
            }
            catch (System.Exception ex)
            {
                //Login.Profile.ErrorHandling(ex, this, "AddressInformation", "FillAddressByObjectNameReferenceID");
            }
        }