Esempio n. 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            SendOrderReportData ds = new SendOrderReportData();
            DataTable SendOrderHeader = ds.Tables["SendOrderHeader"];
            DataTable SendOrderDetail = ds.Tables["SendOrderDetail"];
            DataTable SendOrderFooter = ds.Tables["SendOrderFooter"];

            var cmd = new OrderService();
            ORDER item = cmd.Select(Convert.ToInt32(ViewState["orderId"]));
            var cmdStore = new StoreService();
            item.STORE = cmdStore.Select(item.STORE_ID);
            var cmdOrderdetail = new OrderDetailService();
            item.ORDER_DETAIL = cmdOrderdetail.GetALLInclude(item.ORDER_ID);
            DataRow drSendOrderHeader = SendOrderHeader.NewRow();
            drSendOrderHeader["STORE_NAME"] = item.STORE.STORE_NAME;
            drSendOrderHeader["STORE_ADDR"] = item.STORE.STORE_ADDR1;
            drSendOrderHeader["STORE_TEL"] = item.STORE.STORE_TEL1;
            if (item.STORE.STORE_TEL2 != "")
            {
                drSendOrderHeader["STORE_TEL"] += ("," + item.STORE.STORE_TEL2);
            }
            drSendOrderHeader["STORE_CODE"] = item.STORE.STORE_CODE;
            drSendOrderHeader["ORDER_DATE"] = item.ORDER_DATE.Value.ToShortDateString();
            drSendOrderHeader["SEND_DATE"] = DateTime.Now.ToShortDateString();
            drSendOrderHeader["ZONE_NAME"] = item.STORE.ZONE.ZONE_NAME;
            drSendOrderHeader["VEHICLE_REG"] = ddlVehicle.SelectedItem.Text;
            SendOrderHeader.Rows.Add(drSendOrderHeader);
            int seq = 1;
            decimal sumWeight = 0;
            foreach (ORDER_DETAIL od in item.ORDER_DETAIL)
            {
                DataRow drSendOrderDetail = SendOrderDetail.NewRow();
                drSendOrderDetail["SEQ"] = seq.ToString();
                drSendOrderDetail["NAME"] = od.PRODUCT.PRODUCT_NAME;
                drSendOrderDetail["QTY"] = (od.PRODUCT_QTY - od.PRODUCT_SEND_QTY).ToString();
                drSendOrderDetail["PACKAGE"] = od.PRODUCT.PRODUCT_PACKING_DESC;
                drSendOrderDetail["WEIGHT"] = od.PRODUCT.PRODUCT_WEIGHT;
                drSendOrderDetail["SUM_WEIGHT"] = (od.PRODUCT.PRODUCT_WEIGHT * (od.PRODUCT_QTY - od.PRODUCT_SEND_QTY)).ToString();
                sumWeight += (od.PRODUCT.PRODUCT_WEIGHT * (od.PRODUCT_QTY - od.PRODUCT_SEND_QTY)).Value;
                SendOrderDetail.Rows.Add(drSendOrderDetail);
                seq++;
            }

            DataRow drSendOrderFooter = SendOrderFooter.NewRow();
            drSendOrderFooter["SUM_WEIGHT_TH"] = ThaiBaht(sumWeight.ToString());
            drSendOrderFooter["SUM_WEIGHT_NUMBER"] = sumWeight.ToString();
            SendOrderFooter.Rows.Add(drSendOrderFooter);

            Session["SendOrderReportData"] = ds;
            Response.Redirect("../Reports/SendOrder.aspx");
        }
Esempio n. 2
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");
        }
Esempio n. 3
0
        private void InitialData()
        {
            Session["lstOrderDetail"] = null;
            var cmdStore = new StoreService();
            //DataSouce = cmdStore.GetALL();
            DataSouce = new List<STORE>();
            USER user = Session["user"] as USER;
            if (user == null) Response.Redirect("MainAdmin.aspx");
            var cmdZone = new ZoneDetailService();
            foreach (ZONE_DETAIL zoneId in cmdZone.GetALLByUser(user.EMPLOYEE_ID))
            {
                List<STORE> tmp = cmdStore.GetALL().Where(x => x.ZONE_ID == zoneId.ZONE_ID).ToList();
                DataSouce.AddRange(tmp);
            }

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

            gridStore.DataSource = null;
            gridStore.DataBind();
        }
Esempio 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";
                }
            }
        }
Esempio n. 5
0
 private void InitialData()
 {
     var cmd = new StoreService();
     DataSouce = cmd.GetALL();
     gridStore.DataSource = DataSouce;
     gridStore.DataBind();
 }
Esempio n. 6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int orderId = Convert.ToInt32(ViewState["orderId"]);
            var cmd = new OrderDetailService();
            DataSouceDetail = cmd.GetALLInclude().Where(x => x.ORDER_ID == orderId && x.PRODUCT_QTY != x.PRODUCT_SEND_QTY).ToList();
            int i = 0;
            int index = 0;
            DELIVERY_ORDER od = new DELIVERY_ORDER();
            od.DELIVERY_ORDER_DETAIL = new List<DELIVERY_ORDER_DETAIL>();
            var cmdDO = new DeliveryOrderService(od);
            foreach (ORDER_DETAIL item in DataSouceDetail)
            {
                if (Convert.ToInt32(((TextBox)gridProductDetail.Rows[i].Cells[4].FindControl("txtQty")).Text) > 0)
                {
                    item.PRODUCT_SEND_QTY += Convert.ToInt32(((TextBox)gridProductDetail.Rows[i].Cells[4].FindControl("txtQty")).Text);
                    DELIVERY_ORDER_DETAIL dod = new DELIVERY_ORDER_DETAIL();
                    dod.PRODUCT_ID = item.PRODUCT_ID;
                    dod.PRODUCT_PRICE = item.PRODUCT_PRICE;
                    dod.PRODUCT_QTY = item.PRODUCT_QTY;
                    dod.PRODUCT_SEND_QTY = Convert.ToInt32(((TextBox)gridProductDetail.Rows[i].Cells[4].FindControl("txtQty")).Text);
                    dod.PRODUCT_SEQ = (++index);
                    dod.PRODUCT_TOTAL = item.PRODUCT_TOTAL;
                    dod.CREATE_DATE = DateTime.Now;
                    dod.CREATE_EMPLOYEE_ID = 0;
                    dod.UPDATE_DATE = DateTime.Now;
                    dod.UPDATE_EMPLOYEE_ID = 0;
                    dod.SYE_DEL = true;
                    od.DELIVERY_ORDER_DETAIL.Add(dod);
                }
                i++;
            }
            od.DELORDER_DATE = DateTime.Now;
            od.DELORDER_STEP = "1";
            od.ORDER_ID = orderId;
            od.VEHICLE_ID = Convert.ToInt32(ddlVehicle.SelectedValue);
            od.CREATE_DATE = DateTime.Now;
            od.CREATE_EMPLOYEE_ID = 0;
            od.UPDATE_DATE = DateTime.Now;
            od.UPDATE_EMPLOYEE_ID = 0;
            od.SYE_DEL = true;
            cmdDO.Add();
            od.DELORDER_CODE = "IV" + od.DELORDER_ID;
            cmdDO.Edit();
            cmd = new OrderDetailService(DataSouceDetail);
            cmd.UpdateList();

            SendOrderReportData ds = new SendOrderReportData();
            DataTable SendOrderHeader = ds.Tables["SendOrderHeader"];
            DataTable SendOrderDetail = ds.Tables["SendOrderDetail"];
            DataTable SendOrderFooter = ds.Tables["SendOrderFooter"];

            var cmdOrder = new OrderService();
            ORDER Order = cmdOrder.Select(orderId);
            var cmdStore = new StoreService();
            od.STORE = cmdStore.Select(Order.STORE_ID);
            var cmdOrderdetail = new DeliveryOrderDetailService();
            od.DELIVERY_ORDER_DETAIL = cmdOrderdetail.GetALLInclude(od.DELORDER_ID);
            DataRow drSendOrderHeader = SendOrderHeader.NewRow();
            drSendOrderHeader["STORE_NAME"] = od.STORE.STORE_NAME;
            drSendOrderHeader["STORE_ADDR"] = od.STORE.STORE_ADDR1;
            drSendOrderHeader["STORE_TEL"] = od.STORE.STORE_TEL1;
            if (od.STORE.STORE_TEL2 != "")
            {
                drSendOrderHeader["STORE_TEL"] += ("," + od.STORE.STORE_TEL2);
            }
            drSendOrderHeader["STORE_CODE"] = od.STORE.STORE_CODE;
            drSendOrderHeader["ORDER_DATE"] = od.DELORDER_DATE.Value.ToShortDateString();
            drSendOrderHeader["SEND_DATE"] = DateTime.Now.ToShortDateString();
            drSendOrderHeader["ZONE_NAME"] = od.STORE.ZONE.ZONE_NAME;
            drSendOrderHeader["VEHICLE_REG"] = ddlVehicle.SelectedItem.Text;
            SendOrderHeader.Rows.Add(drSendOrderHeader);
            int seq = 1;
            decimal sumWeight = 0;
            foreach (DELIVERY_ORDER_DETAIL dodItem in od.DELIVERY_ORDER_DETAIL)
            {
                if (dodItem.PRODUCT_SEND_QTY > 0)
                {
                    DataRow drSendOrderDetail = SendOrderDetail.NewRow();
                    drSendOrderDetail["SEQ"] = seq.ToString();
                    drSendOrderDetail["NAME"] = dodItem.PRODUCT.PRODUCT_NAME;
                    drSendOrderDetail["QTY"] = dodItem.PRODUCT_SEND_QTY.ToString();
                    drSendOrderDetail["PACKAGE"] = dodItem.PRODUCT.PRODUCT_PACKING_DESC;
                    drSendOrderDetail["WEIGHT"] = dodItem.PRODUCT.PRODUCT_WEIGHT;
                    drSendOrderDetail["SUM_WEIGHT"] = (dodItem.PRODUCT.PRODUCT_WEIGHT * dodItem.PRODUCT_SEND_QTY).ToString();
                    sumWeight += (dodItem.PRODUCT.PRODUCT_WEIGHT * dodItem.PRODUCT_SEND_QTY).Value;
                    SendOrderDetail.Rows.Add(drSendOrderDetail);
                    seq++;
                }
            }

            DataRow drSendOrderFooter = SendOrderFooter.NewRow();
            drSendOrderFooter["SUM_WEIGHT_TH"] = ThaiBaht(sumWeight.ToString());
            drSendOrderFooter["SUM_WEIGHT_NUMBER"] = sumWeight.ToString();
            SendOrderFooter.Rows.Add(drSendOrderFooter);

            Session["SendOrderReportData"] = ds;
            Response.Redirect("../Reports/SendOrder.aspx");
        }
Esempio n. 7
0
        protected void btnPrint_Click(object sender, EventArgs e)
        {
            List<STORE> list = new List<STORE>();
            var cmd = new StoreService();
            for (int i = 0; i < grideInOrder.Rows.Count; i++)
            {
                if (list.Where(x => x.STORE_ID == Convert.ToInt32(grideInOrder.DataKeys[i].Values[1].ToString())).FirstOrDefault() == null)
                {
                    list.Add(cmd.Select(Convert.ToInt32(grideInOrder.DataKeys[i].Values[1].ToString())));
                }
            }

            List<InOrderForPrint> listInOrder = new List<InOrderForPrint>();
            var cmdOrder = new OrderService();
            var cmdOrderDetail = new OrderDetailService();
            List<ORDER> tmpListOrder = new List<ORDER>();
            foreach (STORE tmp in list)
            {
                InOrderForPrint inOrder = new InOrderForPrint();
                inOrder.Store = tmp;
                inOrder.OrderDetails = new List<ORDER_DETAIL>();
                tmpListOrder = cmdOrder.GetALLIncludeByStore(tmp.STORE_ID);
                foreach (ORDER tmpOrder in tmpListOrder)
                {
                    inOrder.Order = tmpOrder;
                    inOrder.OrderDetails.AddRange(cmdOrderDetail.GetALLIncludeByOrder(tmpOrder.ORDER_ID).ToList());
                }
                listInOrder.Add(inOrder);
            }
            InOrderReportData ds = new InOrderReportData();
            DataTable dt = ds.Tables["Data"];
            DataTable dt2 = ds.Tables["Data2"];

            List<ListOfLineForPrint> lstHead = new List<ListOfLineForPrint>();
            foreach (InOrderForPrint item in listInOrder)
            {
                List<LineForPrint> lstLine = new List<LineForPrint>();
                ListOfLineForPrint tmpList = new ListOfLineForPrint();
                tmpList.LineForPrint = new List<LineForPrint>();
                LineForPrint linePrint = new LineForPrint();
                linePrint.line1 = ConvertDateToThai(item.Order.ORDER_DATE.Value);
                if (item.Store.PROVINCE_ID == 1)
                {
                    linePrint.line2 = item.Store.STORE_NAME + " (" + item.Store.STORE_CODE.Substring(item.Store.STORE_CODE.Length - 3, 3) + " )";
                }
                else
                {
                    linePrint.line2 = item.Store.STORE_CODE + " " + item.Store.STORE_NAME;
                }
                linePrint.line3 = "จำนวน";
                linePrint.line4 = "";
                linePrint.line5 = "ราคาต่อชิ้น";
                lstLine.Add(linePrint);

                foreach (ORDER_DETAIL od in item.OrderDetails)
                {
                    LineForPrint linePrintItem = new LineForPrint();
                    linePrintItem.line1 = "";
                    if (od.IS_FREE.Value)
                    {
                        linePrintItem.line2 = "แถม";
                    }
                    else
                    {
                        linePrintItem.line2 = od.PRODUCT.PRODUCT_NAME;
                    }
                    linePrintItem.line3 = od.PRODUCT_QTY.ToString();
                    linePrintItem.line4 = "";
                    linePrintItem.line5 = od.PRODUCT_PRICE.ToString();
                    lstLine.Add(linePrintItem);
                }
                tmpList.LineForPrint.AddRange(lstLine);
                lstHead.Add(tmpList);
            }

            DataRow dr1;
            int indexData1 = 0;
            for (int i = 0; i < lstHead.Count; i++)
            {
                for (int j = 0; j < lstHead[i].LineForPrint.Count; j++)
                {
                    dr1 = dt.NewRow();
                    dr1["LINEX"] = indexData1++;
                    dr1["LINE1"] = lstHead[i].LineForPrint[j].line1;
                    dr1["LINE2"] = lstHead[i].LineForPrint[j].line2;
                    dr1["LINE3"] = lstHead[i].LineForPrint[j].line3;
                    dr1["LINE4"] = lstHead[i].LineForPrint[j].line4;
                    dr1["LINE5"] = lstHead[i].LineForPrint[j].line5;
                    dt.Rows.Add(dr1);
                }

                for (int k = 0; k < 5; k++)
                {
                    dr1 = dt.NewRow();
                    dr1["LINEX"] = indexData1++;
                    dr1["LINE1"] = "";
                    dr1["LINE2"] = "";
                    dr1["LINE3"] = "";
                    dr1["LINE4"] = "";
                    dr1["LINE5"] = "";
                    dt.Rows.Add(dr1);
                }
            }

            Session["DataToReport"] = ds;
            Response.Redirect("../Reports/InOrder.aspx");
        }
Esempio n. 8
0
        private void InitialData()
        {
            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 cmdStore = new StoreService();
            ViewState["listStore"] = cmdStore.GetALL();
            foreach (var item in (List<STORE>)ViewState["listStore"])
            {
                ddlStore.Items.Add(new ListItem(item.STORE_NAME, item.STORE_ID.ToString()));
            }

            var cmdOrder = new OrderService();
            DataSouce = cmdOrder.GetALLIncludeStore();
            grideInOrder.DataSource = DataSouce;
            grideInOrder.DataBind();
        }