Example #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");
        }
Example #2
0
 private void InitialData()
 {
     var cmd = new OrderService();
     DataSouce = cmd.GetALLIncludeStore();
     gridStore.DataSource = DataSouce;
     gridStore.DataBind();
 }
Example #3
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");
        }
Example #4
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (lstOrderDetail != null && lstOrderDetail.Count > 0)
     {
         ORDER order = new ORDER();
         var cmd = new OrderService(order);
         order.Action = ActionEnum.Create;
         order.ORDER_CODE = "";
         order.ORDER_DATE = System.DateTime.Now;
         order.ORDER_STEP = "1";
         order.ORDER_TOTAL = Convert.ToDecimal(lblPrice.Text);
         order.ORDER_APPROVE = "2";
         order.STORE_ID = ((STORE)ViewState["store"]).STORE_ID;
         order.SYE_DEL = true;
         order.CREATE_DATE = System.DateTime.Now;
         order.CREATE_EMPLOYEE_ID = 0;
         order.UPDATE_DATE = System.DateTime.Now;
         order.UPDATE_EMPLOYEE_ID = 0;
         int i = 1;
         foreach (ORDER_DETAIL od in lstOrderDetail)
         {
             od.PRODUCT_SEQ = i++;
         }
         order.ORDER_DETAIL = lstOrderDetail;
         cmd.Add();
         order.ORDER_CODE = "IV" + order.ORDER_ID;
         cmd.Edit();
         Response.Redirect("MainAdmin.aspx");
     }
 }
Example #5
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");
        }
Example #6
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();
        }