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; } }
private void InitialDataPopup() { 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 cmdPro = new ProductService(); var listddlPakUDesc = cmdPro.GetUDescPacking(); foreach (var item in listddlPakUDesc) { ddlPakUDesc.Items.Add(new ListItem(item, item)); } var listddlPakPDesc = cmdPro.GetPDescPacking(); foreach (var item in listddlPakPDesc) { ddlPakPDesc.Items.Add(new ListItem(item, item)); } var cmd = new ZoneService(); var listZone = cmd.GetALL(); DataSouceList = new List<PRODUCT_PRICELIST>(); foreach (var item in listZone) { PRODUCT_PRICELIST pd = new PRODUCT_PRICELIST(); pd.ZONE_ID = item.ZONE_ID; pd.ZONE = new ZONE(); pd.ZONE.ZONE_CODE = item.ZONE_CODE; pd.ZONE.ZONE_NAME = item.ZONE_NAME; DataSouceList.Add(pd); } if (ViewState["proId"] != null) { _product = cmdPro.Select(Convert.ToInt32(ViewState["proId"].ToString())); popTxtProductCode.Text = _product.PRODUCT_CODE; poptxtProductName.Text = _product.PRODUCT_NAME; txtPacking.Text = _product.PRODUCT_PACKING_QTY.ToString(); //txtPackingDesc.Text = _product.PRODUCT_PACKING_DESC; txtWeight.Text = _product.PRODUCT_WEIGHT.ToString(); txtUnit.Text = _product.PRODUCT_WEIGHT_DEFINE; ddlCategory.SelectedValue = _product.CATEGORY_ID.ToString(); ddlkind.SelectedValue = _product.PRODUCT_TYPE_CODE.ToString(); //txtSize.Text = _product.PRODUCT_SIZE; ddlPakUDesc.SelectedValue = _product.PRODUCT_PACKING_PER_UDESC; ddlPakPDesc.SelectedValue = _product.PRODUCT_PACKING_PER_PDESC; var cmdPD = new ProductPriceListService(); var listPD = cmdPD.Select(Convert.ToInt32(ViewState["proId"].ToString())); foreach (var itemPD in listPD) { foreach (var itemDST in DataSouceList) { if (itemDST.ZONE_ID == itemPD.ZONE_ID) { itemDST.PRODUCT_PRICE = itemPD.PRODUCT_PRICE; itemDST.PRODUCT_ID = itemPD.PRODUCT_ID; break; } } } List<PRODUCT_PROMOTION> listPromotionItem = new List<PRODUCT_PROMOTION>(); var cmdPromotion = new ProductPromotionService(); DataSoucePromotion = cmdPromotion.GetALLIncludeZone(Convert.ToInt32(ViewState["proId"].ToString())); listPromotionItem.AddRange(DataSoucePromotion); listPromotionItem.AddRange(listPromotion); gridPromotion.DataSource = listPromotionItem; gridPromotion.DataBind(); flag.Text = "Edit"; } gridProductDetail.DataSource = DataSouceList; gridProductDetail.DataBind(); }
private void InitialData() { var cmd = new CategoryService(); DataSouce = cmd.GetALL(); gridCategory.DataSource = DataSouce; gridCategory.DataBind(); }