Ejemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var obj = new STORE();
            obj.PROVINCE_ID = Convert.ToInt32(ddlProvince.SelectedValue);
            obj.SECTOR_ID = Convert.ToInt32(ddlSector.SelectedValue);
            obj.ROAD_ID = Convert.ToInt32(ddlRoad.SelectedValue);
            obj.STORE_ADDR1 = txtAddress.Text;
            obj.STORE_CODE = popTxtStoreCode.Text;
            obj.STORE_DISTRICT = txtAmpur.Text;
            obj.STORE_FAX = txtFax.Text;
            obj.STORE_MOBILE = txtMobli.Text;
            obj.STORE_NAME = poptxtStoreName.Text;
            obj.STORE_POSTCODE = txtPostCode.Text;
            obj.STORE_STREET = txtRoad.Text;
            obj.STORE_SUBDISTRICT = txtTumbon.Text;
            obj.STORE_TEL1 = txtTel1.Text;
            obj.STORE_TEL2 = txtTel2.Text;
            obj.ZONE_ID = Convert.ToInt32(ddlZone.SelectedValue);
            var cmd = new StoreService(obj);
            if (flag.Text.Equals("Add"))
            {
                obj.Action = ActionEnum.Create;
                obj.CREATE_DATE = DateTime.Now;
                obj.CREATE_EMPLOYEE_ID = 0;
                obj.UPDATE_DATE = DateTime.Now;
                obj.UPDATE_EMPLOYEE_ID = 0;
                obj.SYE_DEL = true;
                cmd.Add();
            }
            else
            {
                obj.Action = ActionEnum.Update;
                obj.STORE_ID = Convert.ToInt32(ViewState["stoId"].ToString());
                obj.UPDATE_DATE = DateTime.Now;
                obj.UPDATE_EMPLOYEE_ID = 0;
                obj.SYE_DEL = true;
                cmd.Edit();
            }

            ViewState["stoId"] = null;
            Response.Redirect("SearchStore.aspx");
        }
Ejemplo n.º 2
0
 public StoreService(STORE item)
 {
     _item = item;
 }
Ejemplo n.º 3
0
 public List<STORE> GetALL(STORE item)
 {
     using (var ctx = new SPWEntities())
     {
         var list = ctx.STORE.Where(x => x.STORE_CODE.Contains(item.STORE_CODE)).ToList();
         return list;
     }
 }
Ejemplo n.º 4
0
        private void InitialDataPopup()
        {
            var cmd = new SectorService();
            var list = cmd.GetALL();
            foreach (var item in list)
            {
                ddlSector.Items.Add(new ListItem(item.SECTOR_NAME, item.SECTOR_ID.ToString()));
            }
            var cmdPro = new ProvinceService();
            ViewState["listProvince"] = cmdPro.GetALL();
            foreach (var item in (List<PROVINCE>)ViewState["listProvince"])
            {
                ddlProvince.Items.Add(new ListItem(item.PROVINCE_NAME, item.PROVINCE_ID.ToString()));
            }

            var cmdRoad = new RoadService();
            ViewState["listRoad"] = cmdRoad.GetALL();
            foreach (var item in (List<ROAD>)ViewState["listRoad"])
            {
                ddlRoad.Items.Add(new ListItem(item.ROAD_NAME, item.ROAD_ID.ToString()));
            }

            var cmdZone = new ZoneService();
            var listZone = cmdZone.GetALL();
            foreach (var item in listZone)
            {
                ddlZone.Items.Add(new ListItem(item.ZONE_NAME, item.ZONE_ID.ToString()));
            }

            if (ViewState["stoId"] != null)
            {
                var cmdStore = new StoreService();
                _store = cmdStore.Select(Convert.ToInt32(ViewState["stoId"].ToString()));
                if (_store != null)
                {
                    txtAddress.Text = _store.STORE_ADDR1;
                    txtAmpur.Text = _store.STORE_DISTRICT;
                    txtFax.Text = _store.STORE_FAX;
                    txtMobli.Text = _store.STORE_MOBILE;
                    txtPostCode.Text = _store.STORE_POSTCODE;
                    popTxtStoreCode.Text = _store.STORE_CODE;
                    poptxtStoreName.Text = _store.STORE_NAME;
                    txtTel1.Text = _store.STORE_TEL1;
                    txtTel2.Text = _store.STORE_TEL2;
                    txtTumbon.Text = _store.STORE_SUBDISTRICT;
                    ddlSector.SelectedValue = _store.SECTOR_ID.ToString();
                    ddlProvince.SelectedValue = _store.PROVINCE_ID.ToString();
                    ddlProvince.Enabled = true;
                    ddlZone.SelectedValue = _store.ZONE_ID.ToString();
                    //if (ddlProvince.SelectedItem.Text.Equals("กรุงเทพมหานคร"))
                    //{
                    ddlRoad.Visible = true;
                    ddlRoad.SelectedValue = _store.ROAD_ID.ToString();
                    txtRoad.Visible = false;
                    //}
                    //else
                    //{
                    //    txtRoad.Text = _store.STORE_STREET;
                    //    ddlRoad.Visible = false;
                    //}
                    flag.Text = "Edit";
                }
            }
        }
Ejemplo n.º 5
0
        private void InitialData()
        {
            _store = (STORE)Session["store"];
            txtStoreCode.Text = _store.STORE_CODE;
            txtStoreName.Text = _store.STORE_NAME;

            var cmdCat = new CategoryService();
            var list = cmdCat.GetALL();
            foreach (var item in list)
            {
                ddlCategory.Items.Add(new ListItem(item.CATEGORY_NAME, item.CATEGORY_ID.ToString()));
            }

            var cmd = new ProductService();
            DataSouce = cmd.GetALLInclude().Where(x => x.PRODUCT_TYPE_CODE == 1).ToList();
            DataSouceShowProduct = new List<ShowProduct>();
            foreach (PRODUCT pro in DataSouce)
            {
                ShowProduct tmp = new ShowProduct();
                tmp.PRODUCT_ID = pro.PRODUCT_ID;
                tmp.PRODUCT_CODE = pro.PRODUCT_CODE;
                tmp.PRODUCT_NAME = pro.PRODUCT_NAME;
                tmp.PRICE = pro.PRODUCT_PRICELIST.Where(x => x.PRODUCT_ID == pro.PRODUCT_ID && x.ZONE_ID == _store.ZONE_ID).FirstOrDefault()
                    != null ? (decimal)pro.PRODUCT_PRICELIST.Where(x => x.PRODUCT_ID == pro.PRODUCT_ID && x.ZONE_ID == _store.ZONE_ID).FirstOrDefault().PRODUCT_PRICE : 0;
                tmp.CATEGORY_ID = pro.CATEGORY_ID;
                DataSouceShowProduct.Add(tmp);
            }
            gridProduct.DataSource = DataSouceShowProduct;
            gridProduct.DataBind();

            if (lstOrderDetail.Count > 0)
            {
                lblPrice.Text = lstOrderDetail.Select(x => x.PRODUCT_TOTAL).Sum().ToString();
                linkToOrder.Visible = true;
            }
        }