Ejemplo n.º 1
0
        void SearchDTL(int row)
        {
            if (row < 0)
            {
                grd_item.DataSource = null;
                return;
            }

            JsonRequest request = new JsonRequest();

            ProcAction action = request.NewAction();

            action.proc = WebUtil.Values.PROC_SQL;

            StringBuilder sql = new StringBuilder();

            sql.Append("SELECT A.loc_cd, A.prod_cd, B.prod_nm_ko, B.prod_nm, B.unit, ");
            sql.Append(" SUM(A.ord_qty) AS ord_qty, A.unit_price , A.unit_sale_price, A.unit_delv_price, SUM(A.ord_qty) * A.unit_sale_price AS total_prod_price");
            sql.Append(" FROM " + SYS.HBConstant.TB_SO_ORDER_DTL + " A LEFT JOIN " + SYS.HBConstant.TB_MA_PRODUCT + " B ON A.prod_cd = B.prod_cd ");
            sql.Append(" INNER JOIN " + SYS.HBConstant.TB_SO_ORDER + " C ON A.ord_no = C.ord_no AND A.ord_id = C.ord_id ");

            if (scStartDate.DateTime > scEndDate.DateTime)
            {
                DateTime som = DateTime.Today;
                scStartDate.Value = som.ToString("yyyy-MM-dd");
                scEndDate.Value   = som.ToString("yyyy-MM-dd");
            }

            sql.Append(" WHERE (C.up_dt BETWEEN #{start_date} AND #{end_date})");
            action.param.Add(scStartDate.FieldName, scStartDate.DateTime);
            action.param.Add(scEndDate.FieldName, scEndDate.DateTime.AddHours(23).AddMinutes(59).AddSeconds(59));

            sql.Append(" AND (C.loc_cd = #{loc_nm}) ");
            sql.Append(" AND (C.delv_yn = 'Y') ");
            sql.Append(" GROUP BY loc_cd, prod_cd, prod_nm_ko, prod_nm ");
            sql.Append(" ORDER BY prod_cd ");

            action.text = sql.ToString();
            action.param.Add(scLocation.FieldName, grd_view_store.GetRowCellValue(row, "loc_cd"));

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            grd_item.DataSource = ds.Tables[0];
            grd_view_item.RefreshData();
        }
Ejemplo n.º 2
0
        private void gridViewReturn_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            string returnReason;
            int    selRow = gridViewReturn.FocusedRowHandle;

            if (e.Column.FieldName != "ret_reason")
            {
                return;
            }

            returnReason = gridViewReturn.GetRowCellValue(selRow, "ret_reason").ToString();

            // Update return reason on return table

            JsonRequest   request = new JsonRequest();
            StringBuilder sql     = new StringBuilder();

            ProcAction updateReturn = request.NewAction();

            updateReturn.proc = WebUtil.Values.PROC_SQL;

            sql.Append("UPDATE " + HBConstant.TB_SO_RETURN);
            sql.Append(" SET ret_reason = #{ret_reason}, up_id = #{up_id}, up_dt = CURRENT_TIMESTAMP");
            sql.Append(" WHERE ret_id = #{ret_id} AND ret_no = #{ret_no}");

            updateReturn.text = sql.ToString();
            updateReturn.param.Add("ret_reason", returnReason);
            updateReturn.param.Add(HBConstant.C_UP_ID, COM.UserInfo.UserID);
            updateReturn.param.Add("ret_id", gridViewReturn.GetRowCellValue(selRow, "ret_id"));
            updateReturn.param.Add("ret_no", gridViewReturn.GetRowCellValue(selRow, "ret_no"));

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            if (client.check)
            {
                gridViewReturn.RefreshData();
                SearchReturnDetail(selRow);
            }
            else
            {
                //XtraMessageBox.Show("픽업 주문 업데이트 실패 : " + client.message, "실패");
                XtraMessageBox.Show("Có lỗi xảy ra: \n" + client.message, "Lỗi");
            }
            bolCellChanging = false;
        }
Ejemplo n.º 3
0
        public static void OpenTab(string dllName, string className, bool finishDelivery = false)
        {
            if (String.IsNullOrEmpty(dllName) || String.IsNullOrEmpty(className))
            {
                return;
            }

            JsonRequest request = new JsonRequest();

            ProcAction action = request.NewAction();

            action.proc  = "sql";
            action.text  = "SELECT menu_id, menu_name, dll_name, class_name, close_yn, open_yn, menu_type";
            action.text += " FROM tb_sys_menu ";
            action.text += " WHERE dll_name = #{dll_name} AND class_name = #{class_name}";
            action.table = "0";

            action.param.Add("dll_name", dllName);
            action.param.Add("class_name", className);

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            if (ds == null)
            {
                return;
            }

            DataTable dt = ds.Tables["0"];

            MenuTabInfo info = new MenuTabInfo();

            if (dt.Rows.Count == 1)
            {
                info.menuId    = (int)dt.Rows[0]["menu_id"];
                info.menuText  = CommonUtil.Converter.GetNameDictionary(dt.Rows[0]["menu_name"].ToString());
                info.dllName   = dt.Rows[0]["dll_name"] as string;
                info.className = dt.Rows[0]["class_name"] as string;
                info.haveClose = dt.Rows[0]["close_yn"].ToString() == "Y" ? true : false;
                info.canOpen   = dt.Rows[0]["open_yn"].ToString() == "Y" ? true : false;
                info.type      = dt.Rows[0]["menu_type"] as string;

                OpenMenuTap(info, finishDelivery);
            }
        }
Ejemplo n.º 4
0
        void Delete()
        {
            if (gridViewProduct.RowCount == 0)
            {
                return;
            }

            if (bolNewProduct)
            {
                gridViewProduct.DeleteRow(gridViewProduct.FocusedRowHandle);
                bolNewProduct = false;
                return;
            }

            //if (XtraMessageBox.Show("정말로 삭제 하시겠습니까?", "확인", MessageBoxButtons.OKCancel) == DialogResult.OK)
            if (XtraMessageBox.Show("Bạn có thực sự muốn xóa không?", "Xác nhận", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                JsonRequest request = new JsonRequest();
                ProcAction  action  = request.NewAction();
                action.proc = WebUtil.Values.PROC_SQL;

                StringBuilder sql = new StringBuilder();

                sql.Append("DELETE FROM " + SYS.HBConstant.TB_MA_PRODUCT);
                sql.Append(" WHERE prod_cd = #{prod_cd}");

                action.text = sql.ToString();
                action.param.Add(txtProductId.FieldName, txtProductId.Text);

                WebClient client = new WebClient();
                DataSet   ds     = client.Execute(request);

                if (client.check)
                {
                    //XtraMessageBox.Show("삭제 했습니다.", "성공");
                    XtraMessageBox.Show("Xóa thành công.", "Thông báo");
                    Search();
                }
                else
                {
                    //XtraMessageBox.Show("삭제 실패: " + client.message, "실패");
                    XtraMessageBox.Show("Có lỗi xảy ra: \n" + client.message, "Lỗi");
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        void Search()
        {
            JsonRequest request = new JsonRequest();

            ProcAction action = request.NewAction();

            action.proc = WebUtil.Values.PROC_SQL;

            StringBuilder sql = new StringBuilder();

            sql.Append(" CALL hanbibase.get_statistic(#{loc_cd}, #{start_date}, #{end_date})");

            getLocCode();
            if (COM.UserInfo.RoleID == "1")
            {
                action.param.Add("loc_cd", COM.UserInfo.LocCode);
            }
            else if (String.IsNullOrEmpty(scLocation.Text) || String.IsNullOrEmpty(strLocCode))
            {
                sql.Clear();
                sql.Append(" CALL hanbibase.get_statistic(NULL, #{start_date}, #{end_date})");
            }
            else
            {
                action.param.Add("loc_cd", strLocCode);
            }

            if (scStartDate.DateTime > scEndDate.DateTime)
            {
                DateTime som = DateTime.Today;
                scStartDate.Value = som.ToString("yyyy-MM-dd");
                scEndDate.Value   = som.ToString("yyyy-MM-dd");
            }

            action.param.Add(scStartDate.FieldName, scStartDate.DateTime);
            action.param.Add(scEndDate.FieldName, scEndDate.DateTime.AddHours(23).AddMinutes(59).AddSeconds(59));

            action.text = sql.ToString();

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            grd_store.DataSource = ds.Tables[0];
            grd_view_store.RefreshData();
        }
Ejemplo n.º 6
0
        void SearchDTL(int row)
        {
            if (row < 0)
            {
                grd_order.DataSource = null;
                return;
            }

            string supplierCode = grd_view_supplier.GetRowCellValue(row, "supplier_code").ToString();

            if (String.IsNullOrEmpty(supplierCode))
            {
                return;
            }

            JsonRequest request = new JsonRequest();

            ProcAction action = request.NewAction();

            action.proc = WebUtil.Values.PROC_SQL;

            StringBuilder sql = new StringBuilder();

            sql.Append(" CALL hanbibase.get_supplier_dtl(#{supplier_code},#{start_date}, #{end_date})");

            if (scStartDate.DateTime > scEndDate.DateTime)
            {
                DateTime som = DateTime.Today;
                scStartDate.Value = som.ToString("yyyy-MM-dd");
                scEndDate.Value   = som.ToString("yyyy-MM-dd");
            }

            action.param.Add("supplier_code", supplierCode);
            action.param.Add(scStartDate.FieldName, scStartDate.DateTime);
            action.param.Add(scEndDate.FieldName, scEndDate.DateTime.AddHours(23).AddMinutes(59).AddSeconds(59));


            action.text = sql.ToString();
            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            grd_order.DataSource = ds.Tables[0];
            grd_view_order.RefreshData();
        }
Ejemplo n.º 7
0
        void Search()
        {
            // Make Location CD is ReadOnly
            txtLocCd.ReadOnly = true;
            bolNewPickupLoc   = false;

            JsonRequest request = new JsonRequest();

            ProcAction action = request.NewAction();

            action.proc = WebUtil.Values.PROC_SQL;

            StringBuilder sql = new StringBuilder();

            sql.Append("SELECT loc_cd, loc_nm, CAST(IFNULL(loc_post_cd, 0) AS DECIMAL) AS loc_post_cd, IFNULL(loc_addr, '') AS loc_addr, IFNULL(loc_addr_dtl, '') AS loc_addr_dtl");
            sql.Append(" FROM " + SYS.HBConstant.TB_MA_PICKUP_LOC);
            sql.Append(" WHERE loc_nm like concat('%', #{loc_nm}, '%') ");
            if (Decimal.Parse(scPostCode.Text) != 0)
            {
                sql.Append(" AND ( loc_post_cd IS NULL OR loc_post_cd like concat('%', #{loc_post_cd}, '%')) ");
            }
            sql.Append(" AND ( loc_addr IS NULL OR loc_addr like concat('%', #{loc_addr}, '%') OR ");
            sql.Append(" loc_addr_dtl IS NULL OR loc_addr_dtl like concat('%', #{loc_addr}, '%'))");
            sql.Append(" ORDER BY loc_cd ASC ");

            action.text = sql.ToString();
            action.param.Add(scLocName.FieldName, scLocName.Text);
            if (Decimal.Parse(txtPostCode.Text) != 0)
            {
                action.param.Add(scPostCode.FieldName, scPostCode.Text);
            }
            action.param.Add(scAddress.FieldName, scAddress.Text);

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            gridPickupLoc.DataSource = ds.Tables[0];
        }
Ejemplo n.º 8
0
        private static string getNextNo(string prefix)
        {
            string nextNo = String.Empty;

            JsonRequest request = new JsonRequest();
            ProcAction  action  = request.NewAction();

            action.proc = WebUtil.Values.PROC_SQL;

            action.text = " SELECT get_next_no(#{p_prefix}, #{p_no_dt}) AS next_no";
            action.param.Add("p_prefix", prefix);
            action.param.Add("p_no_dt", DateTime.Now.ToString("yyyyMMdd"));

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                nextNo = ds.Tables[0].Rows[0]["next_no"].ToString();
            }

            return(nextNo);
        }
Ejemplo n.º 9
0
        public static string cancelPayment(int ordId)
        {
            JsonRequest jsonRequest = new JsonRequest();

            // Update order stop flag
            ProcAction selectOrder = jsonRequest.NewAction();

            selectOrder.proc = WebUtil.Values.PROC_SQL;
            StringBuilder query = new StringBuilder();

            query.Append(" select id, purchase_info ");
            query.Append(" from kmarket.product_orders ");
            query.Append(" where id = #{ord_id} ");

            selectOrder.text = query.ToString();
            selectOrder.param.Add("ord_id", ordId);

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(jsonRequest);

            if (!client.check || ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
            {
                return("Order ID Error");
            }

            object purchaseInfo = ds.Tables[0].Rows[0]["purchase_info"];

            if (purchaseInfo == DBNull.Value || purchaseInfo == "" || purchaseInfo == null)
            {
                return(null);
            }

            try
            {
                // 요청을 보내는 URI
                string strUri = System.Configuration.ConfigurationSettings.AppSettings["cancelPaymentUrl"];

                // POST, GET 보낼 데이터 입력
                StringBuilder dataParams = new StringBuilder();
                dataParams.Append("order_id=" + ordId);

                // 요청 String -> 요청 Byte 변환
                byte[] byteDataParams = UTF8Encoding.UTF8.GetBytes(dataParams.ToString());

                /* POST */
                // HttpWebRequest 객체 생성, 설정
                System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(strUri);
                request.Method        = "POST"; // 기본값 "GET"
                request.ContentType   = "application/x-www-form-urlencoded";
                request.ContentLength = byteDataParams.Length;

                // 요청 Byte -> 요청 Stream 변환
                Stream stDataParams = request.GetRequestStream();
                stDataParams.Write(byteDataParams, 0, byteDataParams.Length);
                stDataParams.Close();

                // 요청, 응답 받기
                System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    return(null);
                }
                else if ((int)response.StatusCode == 101)
                {
                    return("Order ID Error");
                }
                else if ((int)response.StatusCode == 102)
                {
                    return("Status Error");
                }
                else if ((int)response.StatusCode == 103)
                {
                    return("Refund Error!");
                }
                else
                {
                    return("Server Error!");
                }
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Ejemplo n.º 10
0
        void Save()
        {
            JsonRequest request = new JsonRequest();

            ProcAction action = request.NewAction();

            action.proc = WebUtil.Values.PROC_SQL;

            StringBuilder sql = new StringBuilder();

            // Insert new product
            if (bolNewProduct)
            {
                if (String.IsNullOrEmpty(txtProductId.Text) || SYS.HBConstant.checkExistID(SYS.HBConstant.TB_MA_PRODUCT, txtProductId.FieldName, txtProductId.Text) != SYS.HBConstant.NORMAL)
                {
                    //XtraMessageBox.Show("제품 코드가 잘못되었거나 존재합니다.", "성공");
                    XtraMessageBox.Show("Mã sản phẩm không chính xác hoặc đã tồn tại.", "Lỗi");
                    return;
                }

                sql.Append("INSERT INTO " + SYS.HBConstant.TB_MA_PRODUCT);
                sql.Append(" (prod_cd, prod_nm_ko, prod_nm_en, prod_nm, `desc`, vat_tp, unit, unit_price, in_id, in_dt) ");
                sql.Append(" VALUES (#{prod_cd}, #{prod_nm_ko}, #{prod_nm_en}, #{prod_nm}, #{desc}, #{vat_tp}, #{unit}, #{unit_price}, #{in_id}, CURRENT_TIMESTAMP)");

                action.text = sql.ToString();
                action.param.Add(txtProductId.FieldName, txtProductId.Text);
                action.param.Add(txtProductNameKo.FieldName, txtProductNameKo.Text);
                action.param.Add(txtProductNameEn.FieldName, txtProductNameEn.Text);
                action.param.Add(txtProductName.FieldName, txtProductName.Text);
                action.param.Add(txtDesc.FieldName, txtDesc.Text);
                action.param.Add(chkVat.FieldName, chkVat.Value);
                action.param.Add(txtUnit.FieldName, txtUnit.Text);
                action.param.Add(txtUnitPrice.FieldName, txtUnitPrice.Text);
                action.param.Add(SYS.HBConstant.C_IN_ID, COM.UserInfo.UserID);
            }
            // Update product
            else
            {
                sql.Append("UPDATE " + SYS.HBConstant.TB_MA_PRODUCT);
                sql.Append(" SET prod_nm_ko = #{prod_nm_ko}, prod_nm_en = #{prod_nm_en}, prod_nm = #{prod_nm},");
                sql.Append(" `desc` = #{desc}, vat_tp = #{vat_tp}, unit = #{unit},");
                sql.Append(" unit_price = #{unit_price}, up_id = #{up_id}, up_dt = CURRENT_TIMESTAMP ");
                sql.Append(" WHERE prod_cd = #{prod_cd}");

                action.text = sql.ToString();
                action.param.Add(txtProductNameKo.FieldName, txtProductNameKo.Text);
                action.param.Add(txtProductNameEn.FieldName, txtProductNameEn.Text);
                action.param.Add(txtProductName.FieldName, txtProductName.Text);
                action.param.Add(txtDesc.FieldName, txtDesc.Text);
                action.param.Add(chkVat.FieldName, chkVat.Value);
                action.param.Add(txtUnit.FieldName, txtUnit.Text);
                action.param.Add(txtUnitPrice.FieldName, txtUnitPrice.Text);
                action.param.Add(SYS.HBConstant.C_UP_ID, COM.UserInfo.UserID);
                action.param.Add(txtProductId.FieldName, txtProductId.Text);
            }

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            if (client.check)
            {
                //XtraMessageBox.Show("저장 했습니다.", "성공");
                XtraMessageBox.Show("Lưu thành công.", "Thông báo");
                Search();
            }
            else
            {
                //XtraMessageBox.Show("저장 실패: " + client.message, "실패");
                XtraMessageBox.Show("Có lỗi xảy ra: \n" + client.message, "Lỗi");
            }
        }
Ejemplo n.º 11
0
        void Search()
        {
            JsonRequest request = new JsonRequest();

            ProcAction action = request.NewAction();

            action.proc = WebUtil.Values.PROC_SQL;

            StringBuilder sql = new StringBuilder();

            sql.Append("SELECT A.delv_id, A.delv_no, A.ord_id, A.ord_no, A.loc_cd,");
            sql.Append(" B.loc_nm, A.cust_id, A.full_name, DATE_FORMAT(A.ord_dt, '%Y-%m-%d %T') ord_dt, A.email, A.mobile_no,");
            sql.Append(" A.tel_no, A.delv_tp, D.delv_nm, DATE_FORMAT(A.delv_dt, '%Y-%m-%d %T') delv_dt, A.pay_tp, C.pay_nm, A.pay_info, A.ship_post_cd,");
            sql.Append(" A.ship_addr, A.ship_addr_dtl, A.price_total, A.price_delv, A.price_point, A.price_card, A.price_real, A.price_event_point, A.price_coupon, A.price_cancel,");
            sql.Append(" (A.price_total + A.price_delv - A.price_real - A.price_point - A.price_card - A.price_event_point - A.price_coupon) AS price_dc,"); //price_dc
            sql.Append(" A.delv_yn, E.ret_ord_yn, E.ret_yn, A.delv_dt, E.stop_yn, E.stop_reason");
            sql.Append(" FROM " + HBConstant.TB_SO_DELV + " A");
            sql.Append(" LEFT JOIN " + HBConstant.TB_MA_PICKUP_LOC + " B ON A.loc_cd = B.loc_cd ");
            sql.Append(" LEFT JOIN (SELECT cd as pay_tp, cd_nm as pay_nm FROM tb_sys_code WHERE grp_cd = 'PAY_TP') C ON A.pay_tp = C.pay_tp ");
            sql.Append(" LEFT JOIN (SELECT cd as delv_tp, cd_nm as delv_nm FROM tb_sys_code WHERE grp_cd = 'DELV_TP') D ON A.delv_tp = D.delv_tp ");

            // Right join with tb_so_order
            sql.Append(" RIGHT JOIN " + HBConstant.TB_SO_ORDER + " E ON A.ord_id = E.ord_id AND A.ord_no = E.ord_no");

            // Searching with Location
            if (COM.UserInfo.LocName == scPickupLocation.Text)
            {
                sql.Append(" WHERE A.loc_cd = #{loc_cd}");
                action.param.Add("loc_cd", COM.UserInfo.LocCode);
            }
            else if (!String.IsNullOrEmpty(scPickupLocation.Text))
            {
                sql.Append(" WHERE B.loc_nm like concat('%', #{loc_nm}, '%')");
                action.param.Add(scPickupLocation.FieldName, scPickupLocation.Text);
            }
            else
            {
                sql.Append(" WHERE B.loc_nm like concat('%', #{loc_nm}, '%')");
                action.param.Add(scPickupLocation.FieldName, scPickupLocation.Text);
            }

            // Searching with address
            if (!String.IsNullOrEmpty(scShipAddress.Text))
            {
                sql.Append(" AND (A.ship_addr like concat('%', #{ship_addr}, '%') OR A.ship_addr_dtl like concat('%', #{ship_addr}, '%') )");
                action.param.Add(scShipAddress.FieldName, scShipAddress.Text);
            }

            // Searching with name
            if (!String.IsNullOrEmpty(scFullName.Text))
            {
                sql.Append(" AND A.full_name like concat('%', #{full_name}, '%')");
                action.param.Add(scFullName.FieldName, scFullName.Text);
            }

            // Searching with mobile no or tel no
            if (!String.IsNullOrEmpty(scTelNo.Text))
            {
                sql.Append(" AND (A.mobile_no like concat('%', #{tel_no}, '%') OR A.tel_no like concat('%', #{tel_no}, '%') )");
                action.param.Add(scTelNo.FieldName, scTelNo.Text);
            }

            // Searching with Delivery Status
            if (!String.IsNullOrEmpty(scDelivered.Value.ToString()))
            {
                sql.Append(" AND A.delv_yn = #{delv_yn}");
                action.param.Add(scDelivered.FieldName, scDelivered.Value);
            }

            // Searching with Delivery Status
            if (!String.IsNullOrEmpty(scStopOrder.Value.ToString()))
            {
                sql.Append(" AND E.stop_yn = #{stop_yn}");
                action.param.Add(scStopOrder.FieldName, scStopOrder.Value);
            }

            // TODO Search with date of Order
            if (scStartDate.DateTime <= scEndDate.DateTime)
            {
                sql.Append(" AND (A.in_dt BETWEEN #{start_date} AND #{end_date})");
                action.param.Add(scStartDate.FieldName, scStartDate.DateTime);
                action.param.Add(scEndDate.FieldName, scEndDate.DateTime.AddHours(23).AddMinutes(59).AddSeconds(59));
            }

            sql.Append(" ORDER BY E.stop_yn, A.delv_yn, A.delv_id ASC ");

            action.text = sql.ToString();

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            gridDelivery.DataSource = ds.Tables[0];

            gridViewDelivery.RefreshData();
            if (!String.IsNullOrEmpty(ordNo))
            {
                ChoiceOrd();
            }
        }
Ejemplo n.º 12
0
        void btnSaveCode_Click(object sender, System.EventArgs e)
        {
            if (bolNewGroup)
            {
                //XtraMessageBox.Show("새 코드 그룹을 저장하십시오.", "성공");
                XtraMessageBox.Show("Một nhóm mới đang được thêm, hãy thực hiện lưu nhóm.", "Thông báo");
                btnSaveCode.Focus();
                return;
            }

            JsonRequest request = new JsonRequest();

            ProcAction action = request.NewAction();

            action.proc = WebUtil.Values.PROC_SQL;

            StringBuilder sql = new StringBuilder();
            DataRowView   row;
            string        cd       = String.Empty;
            string        cd_nm    = String.Empty;
            string        grp_cd   = String.Empty;
            int           sort_seq = 0;

            if (gridViewCode.GetSelectedRows().Length > 0)
            {
                row      = (DataRowView)gridViewCode.GetRow(gridViewCode.GetSelectedRows()[0]);
                cd       = row.Row[0].ToString();
                grp_cd   = txtGroupId.Text;
                cd_nm    = row.Row[1].ToString();
                sort_seq = int.Parse(row.Row[4].ToString());
            }

            // Insert new code
            if (bolNewCode)
            {
                if (String.IsNullOrEmpty(cd) || HBConstant.checkExistID(HBConstant.TB_SYS_CODE, "cd", cd) != HBConstant.NORMAL)
                {
                    //XtraMessageBox.Show("이미 존재하거나 비어있는 ID.", "성공");
                    XtraMessageBox.Show("Mã đang trống hoặc đã tồn tại.", "Lỗi");
                    return;
                }

                sql.Append("INSERT INTO " + HBConstant.TB_SYS_CODE);
                sql.Append(" (cd, grp_cd, cd_nm, sort_seq) ");
                sql.Append(" VALUES (#{cd}, #{grp_cd}, #{cd_nm}, #{sort_seq})");

                action.text = sql.ToString();
                action.param.Add("cd", cd);
                action.param.Add("grp_cd", grp_cd);
                action.param.Add("cd_nm", cd_nm);
                action.param.Add("sort_seq", sort_seq);
            }
            // Update code
            else
            {
                sql.Append("UPDATE " + HBConstant.TB_SYS_CODE);
                sql.Append(" SET cd_nm = #{cd_nm}, sort_seq = #{sort_seq}");
                sql.Append(" WHERE cd = #{cd}");

                action.text = sql.ToString();
                action.param.Add("cd_nm", cd_nm);
                action.param.Add("sort_seq", sort_seq);
                action.param.Add("cd", cd);
            }

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            if (client.check)
            {
                //XtraMessageBox.Show("저장 했습니다.", "성공");
                XtraMessageBox.Show("Lưu thành công.", "Thông báo");
                RefreshCode((int)gridViewCodeGroup.GetSelectedRows()[0]);
            }
            else
            {
                //XtraMessageBox.Show("저장 실패: " + client.message, "실패");
                XtraMessageBox.Show("Có lỗi xảy ra: \n" + client.message, "Lỗi");
            }
        }
Ejemplo n.º 13
0
        void Search()
        {
            //Set user ID is ReadOnly
            txtUserID.ReadOnly = true;
            //TODO Permission to change Password
            //if (String.IsNullOrEmpty(COM.UserInfo.UserID) && COM.UserInfo.UserID == txtUserID.Text)
            if (String.IsNullOrEmpty(COM.UserInfo.UserID) && COM.UserInfo.UserID != txtUserID.Text)
            {
                txtPassword.ReadOnly = true;
            }
            bolNewUser = false;

            JsonRequest request = new JsonRequest();

            ProcAction action = request.NewAction();

            action.proc = WebUtil.Values.PROC_SQL;

            StringBuilder sql = new StringBuilder();

            //sql.Append("SELECT A.user_id, A.user_nm, CAST(FROM_BASE64(A.user_pw) AS CHAR CHARACTER SET utf8) as user_pw, A.loc_cd, B.loc_nm, A.use_yn ");
            sql.Append("SELECT A.user_id, A.user_nm, A.user_pw, A.loc_cd, B.loc_nm, A.use_yn, A.role_id, C.role_nm ");
            sql.Append(" FROM " + HBConstant.TB_SYS_USER + " A LEFT JOIN " + HBConstant.TB_MA_PICKUP_LOC + " B ");
            sql.Append(" ON A.loc_cd = B.loc_cd ");
            sql.Append(" LEFT JOIN tb_sys_role C ON A.role_id = C.role_id ");
            sql.Append(" WHERE A.user_nm like concat('%', #{user_nm}, '%') ");

            if (!String.IsNullOrEmpty(scLocation.Text))
            {
                sql.Append(" AND B.loc_nm like concat('%', #{loc_nm}, '%')");
            }

            if (!String.IsNullOrEmpty(scRole.Value.ToString()))
            {
                sql.Append(" AND A.role_id = #{role_id}");
                action.param.Add(scRole.FieldName, scRole.Value);
            }
            sql.Append("    ORDER BY user_id ASC ");

            action.text = sql.ToString();
            action.param.Add(scUserName.FieldName, scUserName.Text);
            action.param.Add(scLocation.FieldName, scLocation.Text);

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            DataTable dt = ds.Tables[0];

            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    try
                    {
                        string pw = COM.AES256.AESDecrypt256(dt.Rows[i]["user_pw"].ToString());
                        dt.Rows[i]["user_pw"] = pw;
                    }
                    catch (Exception err)
                    {
                        dt.Rows[i]["user_pw"] = "";
                    }
                }
            }


            gridUser.DataSource = dt;
        }
Ejemplo n.º 14
0
        public static void PrintPickOrder(string ordNo)
        {
            JsonRequest request = new JsonRequest();

            ProcAction headerAction = request.NewAction();

            headerAction.proc = WebUtil.Values.PROC_SQL;
            StringBuilder sql = new StringBuilder();

            sql.Append("SELECT A.ord_id, A.ord_no, A.loc_cd,");
            sql.Append(" B.loc_nm, A.cust_id, A.full_name, DATE_FORMAT(A.ord_dt, '%Y-%m-%d %T') ord_dt, A.email, A.mobile_no,");
            sql.Append(" A.tel_no, A.delv_tp, D.delv_nm, DATE_FORMAT(A.delv_dt, '%Y-%m-%d %T') delv_dt, A.pay_tp, C.pay_nm, A.pay_info, A.ship_post_cd,");
            sql.Append(" A.ship_addr, A.ship_addr_dtl, A.price_total, A.price_delv, A.price_point, A.price_card, A.price_real,");
            sql.Append(" A.delv_yn");
            sql.Append(" FROM tb_so_order A");
            sql.Append(" LEFT JOIN tb_ma_pickup_loc B ON A.loc_cd = B.loc_cd ");
            sql.Append(" LEFT JOIN (SELECT cd as pay_tp, cd_nm as pay_nm FROM tb_sys_code WHERE grp_cd = 'PAY_TP') C ON A.pay_tp = C.pay_tp ");
            sql.Append(" LEFT JOIN (SELECT cd as delv_tp, cd_nm as delv_nm FROM tb_sys_code WHERE grp_cd = 'DELV_TP') D ON A.delv_tp = D.delv_tp ");
            sql.Append(" WHERE A.ord_no = #{ord_no}");
            headerAction.text = sql.ToString();
            headerAction.param.Add("ord_no", ordNo);

            ProcAction detailAction = request.NewAction();

            detailAction.proc = WebUtil.Values.PROC_SQL;
            sql.Clear();
            sql.Append("SELECT A.pick_dtl_id, A.pick_id, A.pick_no, A.pick_seq, A.prod_cd,");
            sql.Append(" B.prod_nm_ko, B.prod_nm_en, B.prod_nm, A.unit, A.ord_qty, ");
            sql.Append(" C.unit_price, C.unit_sale_price, C.unit_delv_price");
            sql.Append(" FROM tb_so_pick_dtl A ");
            sql.Append(" LEFT JOIN tb_ma_product B ON A.prod_cd = B.prod_cd ");
            sql.Append(" LEFT JOIN tb_so_order_dtl C ON A.ord_id = C.ord_id and A.ord_dtl_id = C.ord_dtl_id ");
            sql.Append(" WHERE A.ord_no = #{ord_no}");
            sql.Append(" ORDER BY A.ord_dtl_id");
            detailAction.text = sql.ToString();
            detailAction.param.Add("ord_no", ordNo);

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            if (!client.check)
            {
                MessageBox.Show(client.message);
            }

            DataTable dtHeader = ds.Tables[0];
            DataTable dtDtl    = ds.Tables[1];

            PrintDocument doc = new PrintDocument();

            doc.PrinterSettings.PrinterName = COM.RawPrinterHelper.printerName;
            doc.PrintPage += new PrintPageEventHandler(doc_PrintPage);

            try
            {
                string str = "";

                str  = "Don hang picking/피킹주문서\n";
                str += "So don hang/주문번호 : " + ordNo + "\n";
                str += "------------------------------------------\n";
                str += "Ten cua hang/매장명 : " + COM.CommonUtils.RemoveDiacritics(COM.UserInfo.LocName) + "\n";
                str += "Dia chi/주소 : " + COM.CommonUtils.RemoveDiacritics(COM.UserInfo.LocAddr) + "\n";
                str += "So dien thoai/전화번호 : " + COM.CommonUtils.RemoveDiacritics(COM.UserInfo.LocTelNo) + "\n";
                str += "------------------------------------------\n";
                str += "Code sp            So luong       Gia tien\n";
                str += "------------------------------------------\n";

                for (int i = 0; i < dtDtl.Rows.Count; i++)
                {
                    string procNmKo = COM.CommonUtils.RemoveDiacritics(dtDtl.Rows[i]["prod_nm_ko"].ToString());
                    str += procNmKo + "\n";
                    string procNm = COM.CommonUtils.RemoveDiacritics(dtDtl.Rows[i]["prod_nm"].ToString());
                    str += procNm + "\n";
                    string prodCd = dtDtl.Rows[i]["prod_cd"].ToString();
                    double qty    = Double.Parse(dtDtl.Rows[i]["ord_qty"].ToString());
                    string ordQty = String.Format("{0:#,###}", qty);
                    double amt    = Double.Parse(dtDtl.Rows[i]["unit_sale_price"].ToString());
                    string sumAmt = String.Format("{0:#,###}", (amt * qty));

                    str += prodCd.PadRight(17, ' ') + ordQty.PadLeft(10, ' ') + sumAmt.PadLeft(15, ' ') + "\n";
                }
                str += "------------------------------------------\n";
                str += "                                                                                                                  \n";
                //str += "                                                                                                                  \n";
                COM.RawPrinterHelper.SendStringToPrinter(COM.RawPrinterHelper.printerName, str);
                COM.RawPrinterHelper.PrintBarcode("#" + ordNo);
                doc.Print();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Print Pick Order Paper");
            }
        }
Ejemplo n.º 15
0
        private void GetSummary()
        {
            intNew        = 0;
            intPicking    = 0;
            intDelivering = 0;
            intWaiting    = 0;
            intCompleted  = 0;
            intTotal      = 0;

            JsonRequest request = new JsonRequest();

            ProcAction action = request.NewAction();

            action.proc = WebUtil.Values.PROC_SQL;
            action.text = "CALL get_summary(#{loc_cd}); ";
            action.param.Add("loc_cd", COM.UserInfo.LocCode);

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            DataTable dt = ds.Tables[0];

            if (dt.Rows.Count == 0 || dt.Rows.Count > 1)
            {
                return;
            }

            intNew        = int.Parse(dt.Rows[0]["new"].ToString());
            labelNew.Text = intNew.ToString();

            intPicking        = int.Parse(dt.Rows[0]["picking"].ToString());
            labelPicking.Text = intPicking.ToString();

            intDelivering        = int.Parse(dt.Rows[0]["delivering"].ToString());
            labelDelivering.Text = intDelivering.ToString();

            intWaiting        = int.Parse(dt.Rows[0]["waiting"].ToString());
            labelWaiting.Text = intWaiting.ToString();

            intCompleted = int.Parse(dt.Rows[0]["completed"].ToString());
            intTotal     = int.Parse(dt.Rows[0]["total"].ToString());
            string lang = AccessDB.GetConfig("lang");

            if (lang == null || lang == "")
            {
                lang = "ko";
            }

            switch (lang)
            {
            case "ko":
                labelSummary.Text = String.Concat("총 주문 : ", intCompleted, "/", intTotal, " 건");
                break;

            case "en":
                labelSummary.Text = String.Concat("Total orders: ", intCompleted, "/", intTotal, " cases");
                break;

            case "vi":
                labelSummary.Text = String.Concat("Tổng đơn hàng: ", intCompleted, "/", intTotal, " đơn");
                break;
            }
        }
Ejemplo n.º 16
0
        public static bool SendEmail(string ord_no)
        {
            bool sendStatus = false;

            SettingEmailHelper();

            if (String.IsNullOrEmpty(ord_no) || UserInfo.LocCode != "0")
            {
                return(false);
            }

            // Get detail order and suppliers
            JsonRequest   request = new JsonRequest();
            StringBuilder sql     = new StringBuilder();

            ProcAction getProducts = request.NewAction();

            getProducts.proc = WebUtil.Values.PROC_SQL;
            sql.Append(" SELECT A.ord_no, A.full_name, A.email, A.mobile_no, A.tel_no, DATE_FORMAT(A.ord_dt, '%Y-%m-%d %T') ord_dt, DATE_FORMAT(A.delv_dt, '%Y-%m-%d %H:%i') delv_dt,");
            sql.Append(" A.pay_tp, A.pay_info, A.ship_addr, A.ship_addr_dtl, ");
            sql.Append(" A.price_real, A.price_delv, (A.price_total + A.price_delv - A.price_real - A.price_point - A.price_card - A.price_event_point - A.price_coupon) AS price_dc, A.price_point, A.price_card, A.price_event_point, A.price_coupon, A.price_total, A.price_cancel,");
            sql.Append(" B.prod_cd, C.title prod_nm_ko, C.title_vi prod_nm, C.main_img, B.ord_qty, B.unit_price, B.unit_sale_price, B.unit_delv_price,");
            sql.Append(" C.supplier_code, D.supplier_nm, D.addr supplier_addr, D.tel_no supplier_tel_no, D.email supplier_email");
            sql.Append(" FROM hanbibase.tb_so_order A LEFT JOIN hanbibase.tb_so_order_dtl B on A.ord_no = B.ord_no AND A.ord_id =  B.ord_id");
            sql.Append(" LEFT JOIN kmarket.products C ON B.prod_cd = C.p_code collate utf8mb4_general_ci");
            sql.Append(" LEFT JOIN kmarket.suppliers D ON C.supplier_code = D.supplier_code");
            sql.Append(" WHERE A.loc_cd = #{loc_cd}");
            sql.Append(" AND A.ord_no = #{ord_no}");

            getProducts.text = sql.ToString();
            getProducts.param.Add("loc_cd", UserInfo.LocCode);
            getProducts.param.Add("ord_no", ord_no);

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            if (!client.check)
            {
                XtraMessageBox.Show(client.message, "Lỗi");
                return(false);
            }

            DataTable dt = ds.Tables[0];

            if (dt.Rows.Count == 0)
            {
                return(false);
            }

            // Check suppliers
            Dictionary <string, string> listSuppliers = new Dictionary <string, string>();
            string supplierCode;
            string supplierEmail;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                supplierCode  = dt.Rows[i]["supplier_code"].ToString();
                supplierEmail = dt.Rows[i]["supplier_email"].ToString();
                if (!String.IsNullOrEmpty(supplierCode) && !String.IsNullOrEmpty(supplierEmail) && !listSuppliers.ContainsKey(supplierCode))
                {
                    listSuppliers.Add(supplierCode, supplierEmail);
                }
            }

            if (listSuppliers.Count == 0)
            {
                //XtraMessageBox.Show("No product which need to send email to the Supplier.", "Info");
                XtraMessageBox.Show("Không có sản phẩm nào cần gửi email cho Nhà cung cấp.", "Thông báo");
                return(true);
            }

            try
            {
                SmtpClient mailclient = new SmtpClient(smtpServer, smtpPort);
                mailclient.EnableSsl   = true;
                mailclient.Credentials = new System.Net.NetworkCredential(credentialUsername, credentialPassword);

                MailMessage message;
                foreach (string key in listSuppliers.Keys)
                {
                    supplierCode  = String.Empty;
                    supplierEmail = String.Empty;

                    supplierCode  = key;
                    supplierEmail = listSuppliers[supplierCode];
                    message       = new MailMessage(credentialUsername, supplierEmail);

                    message.Subject = "[K-MARKET] Đơn đặt hàng số " + ord_no;
                    message.Body    = BuildEmail(dt, supplierCode, listSuppliers.Count).ToString();

                    message.IsBodyHtml = true;

                    mailclient.Send(message);
                }
                sendStatus = true;
            }
            catch (Exception ex)
            {
                sendStatus = false;
                XtraMessageBox.Show(ex.Message, "Thông báo");
            }

            if (sendStatus)
            {
                XtraMessageBox.Show("Đã gửi email thông báo về đơn hàng cho Nhà cung cấp.", "Thông báo");
            }
            return(sendStatus);
        }
Ejemplo n.º 17
0
        void Search()
        {
            if (!String.IsNullOrEmpty(ret_no))
            {
                //if (XtraMessageBox.Show("주문 번호를 받으려고합니다: " + ret_no + ". 멈추시겠습니까?", "확인", MessageBoxButtons.OKCancel) == DialogResult.OK)
                if (XtraMessageBox.Show("Đơn hàng: " + ret_no + " đang được xử lý. \nBạn có muốn tìm kiếm lại hay không?", "Xác nhận", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    ret_no = String.Empty;
                }
                else
                {
                    gridViewReturn.FocusedRowHandle = currentSelected;
                    return;
                }
            }

            bolCellChanging   = false;
            btnRefund.Enabled = false;

            JsonRequest request = new JsonRequest();

            ProcAction action = request.NewAction();

            action.proc = WebUtil.Values.PROC_SQL;

            StringBuilder sql = new StringBuilder();

            sql.Append("SELECT A.ret_id, A.ret_no, A.ord_id, A.ord_no, A.loc_cd,");
            sql.Append(" B.loc_nm, A.cust_id, A.full_name, A.mobile_no,");
            sql.Append(" A.tel_no, A.delv_tp, D.delv_nm, A.pay_tp, C.pay_nm,");
            sql.Append(" A.pay_info, A.ship_addr, A.ship_addr_dtl, DATE_FORMAT(A.ord_dt, '%Y-%m-%d %T') ord_dt, DATE_FORMAT(A.delv_dt, '%Y-%m-%d %T') delv_dt,");

            sql.Append(" F.price_total, F.price_delv, F.price_real, F.price_point, F.price_card, F.price_event_point, F.price_coupon,");
            sql.Append(" F.recv_price_total, F.recv_price_delv, F.recv_price_real, F.recv_price_point, F.recv_price_card, F.recv_price_event_point, F.recv_price_coupon,");
            sql.Append(" A.ret_price_total, A.ret_price_delv, A.ret_price_real, A.ret_price_point, A.ret_price_card, A.ret_price_event_point, A.ret_price_coupon,");

            sql.Append(" A.ret_tp, E.ret_tp_nm, A.ret_yn, DATE_FORMAT(A.ret_dt, '%Y-%m-%d %T') ret_dt, A.ret_reason");
            sql.Append(" FROM " + HBConstant.TB_SO_RETURN + " A");
            sql.Append(" LEFT JOIN " + HBConstant.TB_MA_PICKUP_LOC + " B ON A.loc_cd = B.loc_cd ");
            sql.Append(" LEFT JOIN (SELECT cd as pay_tp, cd_nm as pay_nm FROM tb_sys_code WHERE grp_cd = 'PAY_TP') C ON A.pay_tp = C.pay_tp ");
            sql.Append(" LEFT JOIN (SELECT cd as delv_tp, cd_nm as delv_nm FROM tb_sys_code WHERE grp_cd = 'DELV_TP') D ON A.delv_tp = D.delv_tp ");
            sql.Append(" LEFT JOIN (SELECT cd as ret_tp, cd_nm as ret_tp_nm FROM tb_sys_code WHERE grp_cd = 'RET_TP') E ON A.ret_tp = E.ret_tp ");

            // Right join with tb_so_order
            sql.Append(" LEFT JOIN " + HBConstant.TB_SO_DELV + " F ON A.ord_id = F.ord_id AND A.ord_no = F.ord_no");

            // Searching with Location
            if (COM.UserInfo.LocName == scPickupLocation.Text)
            {
                sql.Append(" WHERE A.loc_cd = #{loc_cd}");
                action.param.Add("loc_cd", COM.UserInfo.LocCode);
            }
            else if (!String.IsNullOrEmpty(scPickupLocation.Text))
            {
                sql.Append(" WHERE B.loc_nm like concat('%', #{loc_nm}, '%')");
                action.param.Add(scPickupLocation.FieldName, scPickupLocation.Text);
            }
            else
            {
                sql.Append(" WHERE B.loc_nm like concat('%', #{loc_nm}, '%')");
                action.param.Add(scPickupLocation.FieldName, scPickupLocation.Text);
            }

            // Searching with address
            if (!String.IsNullOrEmpty(scShipAddress.Text))
            {
                sql.Append(" AND (A.ship_addr like concat('%', #{ship_addr}, '%') OR A.ship_addr_dtl like concat('%', #{ship_addr}, '%') )");
                action.param.Add(scShipAddress.FieldName, scShipAddress.Text);
            }

            // Searching with name
            if (!String.IsNullOrEmpty(scFullName.Text))
            {
                sql.Append(" AND A.full_name like concat('%', #{full_name}, '%')");
                action.param.Add(scFullName.FieldName, scFullName.Text);
            }

            // Searching with mobile no or tel no
            if (!String.IsNullOrEmpty(scTelNo.Text))
            {
                sql.Append(" AND (A.mobile_no like concat('%', #{tel_no}, '%') OR A.tel_no like concat('%', #{tel_no}, '%') )");
                action.param.Add(scTelNo.FieldName, scTelNo.Text);
            }

            // Searching with Return Type
            if (!String.IsNullOrEmpty(scReturnType.Value.ToString()))
            {
                sql.Append(" AND A.ret_tp = #{ret_tp}");
                action.param.Add(scReturnType.FieldName, scReturnType.Value);
            }

            // Searching with Return Status
            if (!String.IsNullOrEmpty(scReturned.Value.ToString()))
            {
                sql.Append(" AND A.ret_yn = #{ret_yn}");
                action.param.Add(scReturned.FieldName, scReturned.Value);
            }

            // TODO Search with date of Order
            if (scStartDate.DateTime <= scEndDate.DateTime)
            {
                sql.Append(" AND (A.ret_dt BETWEEN #{start_date} AND #{end_date})");
                action.param.Add(scStartDate.FieldName, scStartDate.DateTime);
                action.param.Add(scEndDate.FieldName, scEndDate.DateTime.AddHours(23).AddMinutes(59).AddSeconds(59));
            }

            sql.Append(" ORDER BY A.ret_yn, A.ret_id ASC ");

            action.text = sql.ToString();

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            gridReturn.DataSource = ds.Tables[0];

            gridViewReturn.RefreshData();
            if (!String.IsNullOrEmpty(ordNo))
            {
                ChoiceOrd();
            }
        }
Ejemplo n.º 18
0
        private void grd_view_supplier_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            if (e.FocusedRowHandle < 0 || e.FocusedRowHandle >= grd_view_supplier.RowCount)
            {
                return;
            }
            SearchDTL(e.FocusedRowHandle);

            if (grd_view_order.RowCount <= 0)
            {
                return;
            }


            double total_real    = 0;
            double total_product = 0;
            double total_online  = 0;
            double total_offline = 0;
            double total_payment = 0;
            double total_return  = 0;
            double total_gap     = 0;

            double total_delv        = 0;
            double total_dc          = 0;
            double total_point       = 0;
            double total_voucher     = 0;
            double total_event_point = 0;
            double total_coupon      = 0;

            double total_atm  = 0;
            double total_card = 0;
            double total_cod  = 0;

            string ordNo    = String.Empty;
            string chkOrdNo = String.Empty;

            for (int i = 0; i < grd_view_order.RowCount; i++)
            {
                //total_product = total_product + Double.Parse(grd_view_order.GetRowCellValue(i, "price_total").ToString());
                chkOrdNo = grd_view_order.GetRowCellValue(i, "ord_no").ToString();

                double tmp_product = Double.Parse(grd_view_order.GetRowCellValue(i, "price_total").ToString());
                double tmp_dc      = 0;
                double tmp_point   = 0;
                double tmp_voucher = 0;
                double tmp_delv    = 0;
                double tmp_return  = Double.Parse(grd_view_order.GetRowCellValue(i, "total_amt_return").ToString());
                double tmp_real    = 0;

                if (ordNo != chkOrdNo)
                {
                    ordNo       = chkOrdNo;
                    tmp_dc      = 0;
                    tmp_point   = 0;
                    tmp_voucher = 0;
                    tmp_delv    = 0;
                    tmp_real    = 0;

                    JsonRequest request = new JsonRequest();

                    ProcAction action = request.NewAction();
                    action.proc = WebUtil.Values.PROC_SQL;

                    StringBuilder sql = new StringBuilder();
                    sql.Append("SELECT  IFNULL(COUNT(D.supplier_code), 1) AS number_supplier");
                    sql.Append(" FROM hanbibase.tb_so_order A LEFT JOIN hanbibase.tb_so_order_dtl B on A.ord_no = B.ord_no AND A.ord_id =  B.ord_id");
                    sql.Append(" LEFT JOIN kmarket.products C ON B.prod_cd = C.p_code collate utf8mb4_general_ci");
                    sql.Append(" LEFT JOIN kmarket.suppliers D ON C.supplier_code = D.supplier_code");
                    sql.Append(" WHERE A.ord_no = #{ord_no} AND A.stop_yn = 'N';");

                    action.text = sql.ToString();
                    action.param.Add("ord_no", ordNo);

                    WebClient client = new WebClient();
                    DataSet   ds     = client.Execute(request);

                    double count = Double.Parse(ds.Tables[0].Rows[0]["number_supplier"].ToString());

                    tmp_dc      = Double.Parse(grd_view_order.GetRowCellValue(i, "price_dc").ToString()) / count;
                    tmp_point   = Double.Parse(grd_view_order.GetRowCellValue(i, "price_point").ToString()) / count;
                    tmp_voucher = Double.Parse(grd_view_order.GetRowCellValue(i, "price_card").ToString()) / count;
                    tmp_delv    = Double.Parse(grd_view_order.GetRowCellValue(i, "price_delv").ToString()) / count;

                    total_dc      = total_dc + tmp_dc;
                    total_point   = total_point + tmp_point;
                    total_voucher = total_voucher + tmp_voucher;
                    total_delv    = total_delv + tmp_delv;
                    tmp_real      = tmp_product - tmp_dc - tmp_point - tmp_voucher + tmp_delv;
                }
                else
                {
                    tmp_real = tmp_product;
                }
                total_product = total_product + tmp_product;
                total_return  = total_return + tmp_return;
                total_real    = total_real + tmp_real;

                if (grd_view_order.GetRowCellValue(i, "pay_tp").ToString() == "offline")
                {
                    total_offline = total_offline + tmp_real;
                }
                if (grd_view_order.GetRowCellValue(i, "pay_tp").ToString() == "online")
                {
                    total_online = total_online + tmp_real;
                }
                if (grd_view_order.GetRowCellValue(i, "pay_info").ToString() == "CARD")
                {
                    total_card = total_card + tmp_real;
                }
                if (grd_view_order.GetRowCellValue(i, "pay_info").ToString() == "ATM")
                {
                    total_atm = total_atm + tmp_real;
                }
                if (grd_view_order.GetRowCellValue(i, "pay_info").ToString() == "COD")
                {
                    total_cod = total_cod + tmp_real;
                }
            }

            grd_view_supplier.SetRowCellValue(e.FocusedRowHandle, "total_amt_real", total_real);
            grd_view_supplier.SetRowCellValue(e.FocusedRowHandle, "total_amt_payment", total_online + total_offline);
            grd_view_supplier.SetRowCellValue(e.FocusedRowHandle, "total_amt_return", total_return);
            grd_view_supplier.SetRowCellValue(e.FocusedRowHandle, "total_amt_gap", total_real - (total_online + total_offline));
            grd_view_supplier.SetRowCellValue(e.FocusedRowHandle, "total_amt_delv", total_delv);
            grd_view_supplier.SetRowCellValue(e.FocusedRowHandle, "total_amt_dc", total_dc);
            grd_view_supplier.SetRowCellValue(e.FocusedRowHandle, "total_amt_voucher", total_voucher);
            grd_view_supplier.SetRowCellValue(e.FocusedRowHandle, "total_amt", total_product);
            grd_view_supplier.SetRowCellValue(e.FocusedRowHandle, "total_amt_card", total_card);
            grd_view_supplier.SetRowCellValue(e.FocusedRowHandle, "total_amt_atm", total_atm);
            grd_view_supplier.SetRowCellValue(e.FocusedRowHandle, "total_amt_cod", total_cod);
            grd_view_order.RefreshData();
        }
Ejemplo n.º 19
0
        private void btnReturn_HbClick(object sender, System.EventArgs e)
        {
            if (gridViewDelivery.RowCount <= 0 || gridViewDelivery.FocusedRowHandle < 0)
            {
                return;
            }

            if (gridViewDelivery.GetRowCellValue(gridViewDelivery.FocusedRowHandle, "delv_yn").ToString() == "N" ||
                gridViewDelivery.GetRowCellValue(gridViewDelivery.FocusedRowHandle, "ret_yn").ToString() == "Y" ||
                gridViewDelivery.GetRowCellValue(gridViewDelivery.FocusedRowHandle, "stop_yn").ToString() == "Y")
            {
                //XtraMessageBox.Show("Cannot make return because Delivery was not deliverd.", "Error");
                XtraMessageBox.Show("Không thể trả hàng vì đơn giao hàng chưa được giao hoặc đã trả hàng.", "Lỗi");
                return;
            }

            if (XtraMessageBox.Show("Bạn có thực sự muốn trả hàng cho đơn hàng này không?", "Xác nhận", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            {
                return;
            }

            int    selDelvRow = gridViewDelivery.FocusedRowHandle;
            string retNo      = getNextReturnNo();

            if (String.IsNullOrEmpty(retNo))
            {
                return;
            }

            JsonRequest   request = new JsonRequest();
            StringBuilder sql     = new StringBuilder();

            // Update Order
            ProcAction updateOrder = request.NewAction();

            updateOrder.proc = WebUtil.Values.PROC_SQL;

            sql.Append("UPDATE " + HBConstant.TB_SO_ORDER);
            sql.Append(" SET ret_ord_yn = #{ret_ord_yn}, up_id = #{up_id}, up_dt = CURRENT_TIMESTAMP");
            sql.Append(" WHERE ord_id = #{ord_id} AND ord_no = #{ord_no}");

            updateOrder.text = sql.ToString();
            updateOrder.param.Add("ret_ord_yn", "Y");
            updateOrder.param.Add(HBConstant.C_UP_ID, COM.UserInfo.UserID);
            updateOrder.param.Add("ord_id", gridViewDelivery.GetRowCellValue(selDelvRow, "ord_id"));
            updateOrder.param.Add("ord_no", gridViewDelivery.GetRowCellValue(selDelvRow, "ord_no"));

            // Create Delivery
            ProcAction insertReturn = request.NewAction();

            insertReturn.proc = WebUtil.Values.PROC_SQL;

            sql.Clear();
            sql.Append("INSERT INTO " + HBConstant.TB_SO_RETURN);
            sql.Append(" (ret_id, ret_no, ord_id, ord_no, loc_cd,");
            sql.Append(" cust_id, full_name, mobile_no, tel_no, delv_tp,");
            sql.Append(" pay_tp, pay_info, ship_addr, ship_addr_dtl, ord_dt, delv_dt,");
            sql.Append(" ret_yn, ret_tp, ret_dt, in_id, in_dt)");

            sql.Append(" SELECT ord_id, #{ret_no}, ord_id, ord_no, loc_cd,");
            sql.Append(" cust_id, full_name, mobile_no, tel_no, delv_tp,");
            sql.Append(" pay_tp, pay_info, ship_addr, ship_addr_dtl, ord_dt, delv_dt,");
            sql.Append(" #{ret_yn}, #{ret_tp}, CURRENT_TIMESTAMP, #{in_id}, CURRENT_TIMESTAMP");
            sql.Append(" FROM " + HBConstant.TB_SO_DELV);
            sql.Append(" WHERE ord_no = #{ord_no} AND delv_no = #{delv_no}");

            insertReturn.text = sql.ToString();
            insertReturn.param.Add("ret_no", retNo);                                                               // ret_no
            insertReturn.param.Add("ret_yn", "N");                                                                 // ret_yn
            insertReturn.param.Add("ret_tp", "part");                                                              // ret_tp
            insertReturn.param.Add(HBConstant.C_IN_ID, COM.UserInfo.UserID);                                       // in_id
            insertReturn.param.Add("ord_no", gridViewDelivery.GetRowCellValue(selDelvRow, "ord_no"));              // ord_no
            insertReturn.param.Add("delv_no", gridViewDelivery.GetRowCellValue(selDelvRow, "delv_no"));            // delv_no

            // Create Delivery detail
            ProcAction insertReturnDtl = request.NewAction();

            insertReturnDtl.proc = WebUtil.Values.PROC_SQL;

            sql.Clear();
            sql.Append("INSERT INTO " + HBConstant.TB_SO_RETURN_DTL);
            sql.Append(" (ret_id, ret_no, ret_seq, ord_dtl_id, ord_id,");
            sql.Append(" ord_no, ord_seq, loc_cd, prod_cd, prod_nm,");
            sql.Append(" unit, ord_qty, pick_qty, ret_qty, remain_qty, cancel_qty, unit_price,");
            sql.Append(" unit_sale_price, unit_delv_price, in_id, in_dt)");

            sql.Append(" SELECT ord_id, #{ret_no}, delv_seq, ord_dtl_id, ord_id,");
            sql.Append(" ord_no, ord_seq, loc_cd, prod_cd, prod_nm,");
            sql.Append(" unit, ord_qty, pick_qty, #{ret_qty}, ord_qty, cancel_qty, unit_price,");
            sql.Append(" unit_sale_price, unit_delv_price, #{in_id}, CURRENT_TIMESTAMP");
            sql.Append(" FROM " + HBConstant.TB_SO_DELV_DTL);
            sql.Append(" WHERE ord_no = #{ord_no} AND delv_no = #{delv_no} ");

            insertReturnDtl.text = sql.ToString();
            insertReturnDtl.param.Add("ret_no", retNo);                                                                // ret_no
            insertReturnDtl.param.Add("ret_qty", "0");                                                                 // ret_yn
            insertReturnDtl.param.Add(HBConstant.C_IN_ID, COM.UserInfo.UserID);                                        // in_id
            insertReturnDtl.param.Add("ord_no", gridViewDelivery.GetRowCellValue(selDelvRow, "ord_no"));               // ord_no
            insertReturnDtl.param.Add("delv_no", gridViewDelivery.GetRowCellValue(selDelvRow, "delv_no"));             // delv_no

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            if (client.check)
            {
                //XtraMessageBox.Show("피킹 성공.", "성공");
                //Search();
                gridViewDelivery.SetRowCellValue(selDelvRow, "ret_ord_yn", "Y");
                gridViewDelivery.RefreshData();
                gridViewDeliveryDetail.RefreshData();
                gridViewDelivery.FocusedRowHandle = selDelvRow;
                XtraMessageBox.Show("Sẵn sàng trả hàng.", "Thông báo");

                btnReturn.Enabled = false;

                // Print Return receipt
                //COM.PrintFormats.PrintDelivery(gridViewPickup.GetRowCellValue(selPickRow, "ord_no").ToString());

                // Open Return screen
                COM.MainUtils.SetParameter(gridViewDelivery.GetRowCellValue(selDelvRow, "ord_no").ToString(), String.Empty, String.Empty, String.Empty, String.Empty);
                COM.MainUtils.OpenTab("SOD", "SOD_Return");
                COM.MainUtils.ResetParameter();
            }
            else
            {
                //XtraMessageBox.Show("피킹에 실패: " + client.message, "실패");
                XtraMessageBox.Show("Có lỗi xảy ra: \n" + client.message, "Lỗi");
            }
        }
Ejemplo n.º 20
0
        private void btnRefundOrder_HbClick(object sender, EventArgs e)
        {
            JsonRequest request = new JsonRequest();

            StringBuilder sql = new StringBuilder();

            ProcAction retAction = request.NewAction();

            retAction.proc = WebUtil.Values.PROC_SQL;
            sql.Append("update tb_so_return set ret_yn = 'Y', up_id = #{up_id}, up_dt = current_timestamp, ");
            sql.Append(" ret_price_total = #{ret_price_total}, ret_price_real = #{ret_price_real},");
            sql.Append(" ret_reason = #{ret_reason} ");
            sql.Append(" WHERE ord_no = #{ord_no} ");
            retAction.text = sql.ToString();
            retAction.param.Add("up_id", COM.UserInfo.UserID);
            retAction.param.Add("ord_no", etOrdNo.Text);
            retAction.param.Add("ret_price_total", etRetPriceTotal.Value);
            retAction.param.Add("ret_price_real", etRetPriceReal.Value);
            retAction.param.Add("ret_reason", etRetReason.Text);
            retAction.param.Add("store_cd", COM.UserInfo.StoreCd);
            retAction.param.Add("pos_no", COM.UserInfo.PosNo);

            ProcAction logAction = request.NewAction();

            logAction.proc = WebUtil.Values.PROC_SQL;
            sql.Clear();
            sql.Append("insert into tb_log_wms(ord_no, log_type, store_cd, pos_no, sale_dt, sale_tm, tran_no, in_dt, in_id) ");
            sql.Append("values(#{ord_no}, #{log_type}, #{store_cd}, #{pos_no}, date_format(current_timestamp, '%Y%m%d'), date_format(current_timestamp, '%H%i%S'), get_next_tran_no2(#{store_cd}, #{pos_no}, null), current_timestamp, #{in_id}) ");
            logAction.text = sql.ToString();
            logAction.param.Add("ord_no", etOrdNo.Text);
            logAction.param.Add("log_type", "return");
            logAction.param.Add("store_cd", COM.UserInfo.StoreCd);
            logAction.param.Add("pos_no", COM.UserInfo.PosNo);
            logAction.param.Add("in_id", COM.UserInfo.UserID);


            ProcAction ordAction = request.NewAction();

            ordAction.proc = WebUtil.Values.PROC_SQL;
            sql.Clear();
            sql.Append("update tb_so_order set ret_yn = 'Y', up_id = #{up_id}, up_dt = current_timestamp ");
            sql.Append(" WHERE ord_no = #{ord_no}  ");
            ordAction.text = sql.ToString();
            ordAction.param.Add("up_id", COM.UserInfo.UserID);
            ordAction.param.Add("ord_no", etOrdNo.Text);

            ProcAction selectAction = request.NewAction();

            selectAction.proc  = WebUtil.Values.PROC_SQL;
            selectAction.table = "ret";
            sql.Clear();
            sql.Append("select a.sale_dt, a.sale_tm, a.tran_no, date_format(a.in_dt, '%Y%m%d%H%i%S') open_dt, a.pay_info, b.point_no, b.full_name ");
            sql.Append("from tb_so_return a ");
            sql.Append("    left join tb_so_order b on a.ord_no = b.ord_no ");
            sql.Append("where a.ord_no = #{ord_no}  ");
            selectAction.text = sql.ToString();
            selectAction.param.Add("ord_no", etOrdNo.Text);

            ProcAction selectLogAction = request.NewAction();

            selectLogAction.proc  = WebUtil.Values.PROC_SQL;
            selectLogAction.table = "log";
            sql.Clear();
            sql.Append("select a.log_id, a.sale_dt, a.sale_tm, a.tran_no ");
            sql.Append("from tb_log_wms a ");
            sql.Append("where a.ord_no = #{ord_no} ");
            sql.Append("  and a.log_type = 'order' ");
            sql.Append("order by a.log_id desc limit 1 ");
            selectLogAction.text = sql.ToString();
            selectLogAction.param.Add("ord_no", etOrdNo.Text);


            ProcAction itemAction = request.NewAction();

            itemAction.proc  = WebUtil.Values.PROC_SQL;
            itemAction.table = "item";
            sql.Clear();
            sql.Append("select a.prod_cd plu_cd, @RANKT := @RANK + 1 item_seq, c.ex_cd item_cd, c.vndr_cd, concat(c.prod_nm, ' / ', c.prod_nm_ko) plu_nm, ");
            sql.Append("	a.ret_qty sale_qty, a.ret_qty * a.unit_sale_price tot_amt, a.unit_sale_price sale_prc, a.ret_qty * a.unit_price tot_unit, a.unit_price ");
            sql.Append("from tb_so_return_dtl a ");
            sql.Append("	inner join (SELECT @RANK := 0) b ");
            sql.Append("    left join tb_ma_product c on a.prod_cd = c.prod_cd ");
            sql.Append("where a.ord_no = #{ord_no} ");
            sql.Append("  and a.ret_qty > 0 ");
            sql.Append("order by a.ord_seq asc ");
            itemAction.text = sql.ToString();
            itemAction.param.Add("ord_no", etOrdNo.Text);

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            if (client.check)
            {
                gridView.SetFocusedRowCellValue("ret_yn", "Y");
                gridView.SetFocusedRowCellValue("ret_reason", etRetReason.Text);
                gridView.RefreshData();

                DataTable dt     = ds.Tables["ret"];
                DataTable dtLog  = ds.Tables["log"];
                DataTable dtItem = ds.Tables["item"];

                GetAvailPoint(dt, dtLog);
                //double priceTotal = Convert.ToDouble(this.priceTotal);
                //double pricePoint = Convert.ToDouble(this.pricePoint);
                //double priceCard = Convert.ToDouble(this.priceCard);
                //double priceCoupon = Convert.ToDouble(this.priceCoupon);
                //double priceDc = pricePoint + priceCard + priceCoupon;
                //double priceAll = priceTotal - priceDc;

                double priceTotUnit     = 0;
                double priceTotSaleUnit = 0;
                for (int i = 0; i < dtItem.Rows.Count; i++)
                {
                    priceTotUnit     += Convert.ToDouble(dtItem.Rows[i]["tot_unit"].ToString());
                    priceTotSaleUnit += Convert.ToDouble(dtItem.Rows[i]["tot_amt"].ToString());
                }


                JObject wmsRequest = new JObject();

                JObject irtModel = new JObject();
                wmsRequest.Add("IRT_MODEL", irtModel);

                JObject irtHeader = new JObject();
                irtModel.Add("IRT_HEADER", irtHeader);
                irtHeader.Add("WCC", "Q001");
                irtHeader.Add("SALE_DY", dtLog.Rows[0]["sale_dt"].ToString());
                irtHeader.Add("SITE_CD", COM.UserInfo.StoreCd);
                irtHeader.Add("PROG_NO", COM.UserInfo.PosNo);
                irtHeader.Add("RECEIPT_NO", dtLog.Rows[0]["tran_no"].ToString());
                irtHeader.Add("TRAN_FG", "");
                irtHeader.Add("DES_FG", "Y");
                irtHeader.Add("ORG_LEN", "1000");
                irtHeader.Add("STATUS", "");
                irtHeader.Add("EMP_NO", "");
                irtHeader.Add("SYSTEM", "WMSP");

                JObject tranReq = new JObject();
                irtModel.Add("TRAN_REQ", tranReq);
                tranReq.Add("EJ_DATA", new JArray());
                tranReq.Add("SIGN_DATAS", new JArray());
                tranReq.Add("STORE_CD", COM.UserInfo.StoreCd);
                tranReq.Add("POS_NO", COM.UserInfo.PosNo);
                tranReq.Add("RECEIPT_NO", dtLog.Rows[0]["tran_no"].ToString());
                tranReq.Add("SALE_DY", dtLog.Rows[0]["sale_dt"].ToString());
                tranReq.Add("SALE_TM", dtLog.Rows[0]["sale_tm"].ToString());
                tranReq.Add("REG_EMP_NO", "");


                JObject trData = new JObject();
                trData.Add("TRADE_CALL", new JArray());
                trData.Add("TEMP_OFFER_LIST", new JArray());
                trData.Add("STR_CD", COM.UserInfo.StoreCd);
                trData.Add("SALE_DT", dtLog.Rows[0]["sale_dt"].ToString());
                trData.Add("POS_NO", COM.UserInfo.PosNo);
                trData.Add("SALE_TM", dtLog.Rows[0]["sale_tm"].ToString());
                trData.Add("TRAN_NO", dtLog.Rows[0]["tran_no"].ToString());
                trData.Add("TERMINAL_FG", "01");
                trData.Add("MIX_TRAN_FG", "N");
                trData.Add("TRAN_FG", "2");     //반품
                trData.Add("TRANQ_FG", "0");    //수동반품
                trData.Add("SAVE_FG", "");
                //trData.Add("ORG_DT", dt.Rows[0]["sale_dt"].ToString());
                //trData.Add("ORG_TM", dt.Rows[0]["sale_tm"].ToString());
                //trData.Add("ORG_POS_NO", COM.UserInfo.PosNo);
                //trData.Add("ORG_TRAN_NO", dt.Rows[0]["tran_no"].ToString());
                //trData.Add("ORG_DT", dtLog.Rows[0]["sale_dt"].ToString());
                //trData.Add("ORG_TM", dtLog.Rows[0]["sale_tm"].ToString());
                //trData.Add("ORG_POS_NO", COM.UserInfo.PosNo);
                //trData.Add("ORG_TRAN_NO", dtLog.Rows[0]["tran_no"].ToString());
                trData.Add("ORG_DT", "");
                trData.Add("ORG_TM", "");
                trData.Add("ORG_POS_NO", "");
                trData.Add("ORG_TRAN_NO", "");
                trData.Add("JASA_SUMPAY_FG", "");
                trData.Add("JASA_HALBU_FG", "");
                trData.Add("TASA_SUMPAY_FG", "");
                trData.Add("TASA_HALBU_FG", "");
                trData.Add("CHECK_CARD_FG", "");
                trData.Add("CASH_IC_CARD_FG", "");
                trData.Add("GIFT_FG", "");
                trData.Add("TRAN_TYPE_FG", "10");
                trData.Add("CARD_CD", "");
                trData.Add("FOR_FG", "K");
                trData.Add("OPEN_DT", dt.Rows[0]["open_dt"].ToString());
                trData.Add("CLOSE_DT", dtLog.Rows[0]["sale_dt"].ToString() + dtLog.Rows[0]["sale_tm"].ToString());
                trData.Add("CASHIER_ID", "");
                trData.Add("CASHIER_NAME", COM.UserInfo.UserName);
                trData.Add("WON_AMT", 0.0);
                trData.Add("RESON_CD", "3");   //기타사유
                trData.Add("ORG_CASHIER_ID", "");
                trData.Add("CUST_CD", custCd);
                trData.Add("PGM_VER", "A");
                trData.Add("MST_VER", "A");
                trData.Add("POS_FG", "PS01");
                trData.Add("GIFT_FREE_FG", "");
                trData.Add("TAX_INVOICE_FG", "0");
                trData.Add("PUR_LIMIT", "");
                trData.Add("EMPTY_BOTTLE_SALE", "");
                trData.Add("POS_IP", "");
                trData.Add("EVT_NO", null);
                trData.Add("FOREIGNER_NAME", "");
                trData.Add("UNIONPAY_YN", "");
                trData.Add("SPECIALCARD_YN", "");
                trData.Add("PUBLICSERVANT_YN", "");
                trData.Add("LPAY_FG", false);
                trData.Add("VIC_MEMSALE", "");
                trData.Add("VIC_MEM_CHARGE", "");
                trData.Add("VIC_ONEDAY", "");
                trData.Add("SPECIAL_CARD_SALE", "0");
                trData.Add("LIQUOR_BEER_LITER", 0.0);
                trData.Add("LIQUOR_SOJU_LITER", 0.0);
                trData.Add("LIQUOR_FORIEN_LITER", 0.0);
                trData.Add("LIQUOR_OTH_LITER", 0.0);
                trData.Add("DCC_FG", "");
                trData.Add("CREDT_FG", "");
                trData.Add("EMP_DISCOUNTFG", false);
                trData.Add("USER_PWD", null);
                trData.Add("VIC_SALES", false);
                trData.Add("LawDCCStep", "");
                trData.Add("BioPayFlag", false);
                trData.Add("BioOtcNo", "");
                trData.Add("BioCardNm", "");
                trData.Add("BioFlag", false);
                trData.Add("BioModel", "");
                trData.Add("WCardDcApplyFlag", false);
                trData.Add("OverPayFlag", false);
                trData.Add("SALE_AMT", priceTotUnit);
                trData.Add("DC_AMT", priceTotUnit - priceTotSaleUnit);
                trData.Add("TOT_AMT", priceTotSaleUnit);
                JObject trTranSales = new JObject();
                trData.Add("TR_TRAN_SALES", trTranSales);
                JArray trItemList = new JArray();
                trTranSales.Add("TR_ITEM_LIST", trItemList);


                for (int i = 0; i < dtItem.Rows.Count; i++)
                {
                    double qty       = Convert.ToDouble(dtItem.Rows[i]["sale_qty"].ToString());
                    double unitPrice = Convert.ToDouble(dtItem.Rows[i]["unit_price"].ToString());
                    double salePrice = Convert.ToDouble(dtItem.Rows[i]["sale_prc"].ToString());
                    double unitTotal = Convert.ToDouble(dtItem.Rows[i]["tot_unit"].ToString());
                    double saleTotal = Convert.ToDouble(dtItem.Rows[i]["tot_amt"].ToString());

                    JObject item = new JObject();
                    trItemList.Add(item);
                    item.Add("PLU_CD", dtItem.Rows[i]["plu_cd"].ToString());
                    item.Add("ITEM_SEQ", i + 1);
                    item.Add("ITEM_CD", dtItem.Rows[i]["item_cd"].ToString());
                    item.Add("CLASS_CD", "");
                    item.Add("BTL_CD", "");
                    item.Add("WEIGHT_CD", "");
                    item.Add("SALE_QTY", qty);
                    item.Add("TOT_AMT", unitTotal);
                    item.Add("InclusionAddTaxToDiscount", 0.0);
                    item.Add("CURR_SALE_PRC", unitPrice);
                    item.Add("ORG_SALE_PRC", unitPrice);
                    item.Add("NOR_SALE_PRC", unitPrice);
                    item.Add("NEW_PRC_FG", "0");
                    item.Add("ITEM_FG", "0");
                    item.Add("CANCEL_FG", "1");
                    item.Add("PLU_NM", dtItem.Rows[i]["plu_nm"].ToString());
                    item.Add("DC_FG", "02");
                    item.Add("DC_AMT", unitTotal - saleTotal);
                    item.Add("DC_VAL", 0);
                    item.Add("DC_REASON", "");
                    item.Add("ENURI_PER", 0.0);
                    item.Add("ENURI_AMT", 0.0);
                    item.Add("BOTTLE_PRC", 0.0);
                    item.Add("PBOX_PRC", 0.0);
                    item.Add("PBOX_CD", "");
                    item.Add("GREEN_PNT", 0.0);
                    item.Add("VNDR_CD", dtItem.Rows[i]["vndr_cd"].ToString());
                    item.Add("GREEN_PNT2", 0.0);
                    item.Add("SPECIAL_PNT", 0.0);
                    item.Add("FRESH_WEIGHT", 0.0);
                    item.Add("FRESH_QTY", 0.0);
                    item.Add("FRESH_DC_STICKER", "");
                    item.Add("PUBLIC_SERVANT_FLAG", "");
                    item.Add("TAX_FG", "2");
                    item.Add("TR_ITEM_DETAIL", null);
                    item.Add("OfferNmList", new JArray());
                    item.Add("TAX_RT", 0.0);
                    item.Add("GEO_FG", "1");
                    item.Add("RTNRESN_CODE", "");
                    item.Add("OriginalPrice", 0.0);
                    item.Add("TR_ITEM_COUPON", new JArray());
                    item.Add("REMARK", "");
                    item.Add("DESCRIPTION", "");
                    item.Add("SpecialCardNo", "");
                    item.Add("SpecialCardNoMask", "");
                    item.Add("INFANTFG", "");
                    item.Add("ITEMINFO", "");
                    item.Add("ITEM_LOCAL_CHECK", false);
                    item.Add("CalcPrice", salePrice);
                    item.Add("Position", 0);
                    item.Add("LIQUORFG", "000");
                    item.Add("LIQUOR_TOT_QTY", 0.0);
                    item.Add("STATFG", "1");
                    item.Add("DISP_UNIT", "");
                    item.Add("DISPTOTQTY", 0.0);
                    item.Add("DISPBASEQTY", 0.0);
                    item.Add("L3CD", "");
                    item.Add("PURCHASE_CAP_AMT", 0.0);
                    item.Add("EMP_DC_RT", 0.0);
                    item.Add("EMP_DC_EXCT_FG", "");
                    item.Add("PNT_EXCT_FG", "Y");
                    item.Add("DC_CPN_EXCT_FG", "");
                    item.Add("PNT_CPN_EXCT_FG", "");
                    item.Add("RCPT_CAMPAING_EXCT_FG", "");
                    item.Add("MINOR_LIMIT_FG", "");
                    item.Add("PIZZA_PRT_FG", "");
                    item.Add("ITEMFILLER1", dtItem.Rows[i]["plu_cd"].ToString());
                    item.Add("OFFERPLUPRTFG", "");
                    item.Add("OFFER_PLU_PRT_MARK", "");
                    item.Add("DISCOUNT_TYPE", "");
                    item.Add("EXPIRATION_DATE", "");
                    item.Add("PURCHASE_CAP_OVER_FG", false);
                    item.Add("OIL_AMT", 0.0);
                    item.Add("SCALE_FLAG", false);
                    item.Add("GOODS_RATE_CD", "00");
                    item.Add("itemWonAmt", 0.0);
                    item.Add("Subtotal", saleTotal);
                    item.Add("TaxSubtotal", saleTotal);
                    item.Add("GreenPntSum", 0.0);
                    item.Add("GreenSpecialPntSum", 0.0);
                    item.Add("DiscountTotal", unitTotal - saleTotal);
                    item.Add("TAX_AMT", 0);
                    item.Add("LOTTE_CARD_VOUCHER", "");
                    item.Add("POINT_RESERVE_RATE", 1.0);
                    item.Add("SALE_EVENT_DIV", "1");
                    item.Add("SALE_EVENT_NO", "");
                    item.Add("SALE_PRICE", salePrice);
                    item.Add("GROUP_EVENT_DIV", "1");
                    item.Add("GROUP_EVENT_NO", "");
                    item.Add("GROUP_PRICE_CD", "00");
                    item.Add("POINT_APP_AMT", 0.0);
                    item.Add("DEAL_TIME", dtLog.Rows[0]["sale_tm"].ToString());
                    JObject groupCdHash = new JObject();
                    item.Add("groupCdHash", groupCdHash);
                    groupCdHash.Add("00", Convert.ToDouble(dtItem.Rows[i]["tot_amt"].ToString()));
                    groupCdHash.Add("01", Convert.ToDouble(dtItem.Rows[i]["tot_amt"].ToString()));
                    groupCdHash.Add("02", Convert.ToDouble(dtItem.Rows[i]["tot_amt"].ToString()));
                    groupCdHash.Add("03", Convert.ToDouble(dtItem.Rows[i]["tot_amt"].ToString()));
                    groupCdHash.Add("04", Convert.ToDouble(dtItem.Rows[i]["tot_amt"].ToString()));
                    groupCdHash.Add("05", Convert.ToDouble(dtItem.Rows[i]["tot_amt"].ToString()));
                    groupCdHash.Add("06", Convert.ToDouble(dtItem.Rows[i]["tot_amt"].ToString()));
                    groupCdHash.Add("07", Convert.ToDouble(dtItem.Rows[i]["tot_amt"].ToString()));
                    groupCdHash.Add("08", Convert.ToDouble(dtItem.Rows[i]["tot_amt"].ToString()));
                    groupCdHash.Add("09", Convert.ToDouble(dtItem.Rows[i]["tot_amt"].ToString()));
                    item.Add("GOODS_REGI_FG", "0");
                    item.Add("GOODS_REASON_DTL", null);
                    item.Add("Returntotal", saleTotal);
                    item.Add("DATA_STATE", "3");
                }

                JArray trTenderList = new JArray();
                trTranSales.Add("TR_TENDER_LIST", trTenderList);

                int seq = 0;
                if (priceTotSaleUnit > 0)
                {
                    seq++;
                    JObject tender = new JObject();
                    trTenderList.Add(tender);
                    tender.Add("TENDER_SEQ", seq);
                    tender.Add("TRAN_FG", "");
                    tender.Add("GOODS_TRAN_FG", "1");
                    tender.Add("RECEIVE_AMOUNT", priceTotSaleUnit);
                    tender.Add("SUBTOTAL_AMOUNT", priceTotSaleUnit);
                    JArray cashList = new JArray();
                    tender.Add("TR_TENDER_CASH", cashList);
                    tender.Add("TENDER_FG", "CA01");
                    JObject cash = new JObject();
                    cashList.Add(cash);
                    cash.Add("TENDER_SEQ", 1);
                    cash.Add("CASH_FG", "CA01");
                    cash.Add("RCV_AMT", priceTotSaleUnit);
                    cash.Add("PAY_AMT", priceTotSaleUnit);
                    cash.Add("CHG_AMT", 0);
                    tender.Add("TENDER_NM", "");
                }

                JObject trCashReceipt = new JObject();
                trTranSales.Add("TR_CASHRECEIPT", trCashReceipt);
                trCashReceipt.Add("NET_AMT", priceTotSaleUnit);
                trCashReceipt.Add("TAX_AMT", 0.0);
                trCashReceipt.Add("SVC_AMT", 0.0);
                trCashReceipt.Add("TOT_AMT", priceTotSaleUnit);
                trCashReceipt.Add("CASHBILL_FG", "");
                trCashReceipt.Add("APPLY_FG", "");
                trCashReceipt.Add("INPUT_DATA_FG", "");
                trCashReceipt.Add("INPUT_DATA", "");
                trCashReceipt.Add("INPUT_DATA_MASK", "");
                trCashReceipt.Add("INPUT_FG", "01");
                trCashReceipt.Add("APPLY_NO", "");
                trCashReceipt.Add("AUTO_APPLY_FG", "00");
                trCashReceipt.Add("VENDOR_CD", "");
                trCashReceipt.Add("LPOINT_CASHBILL_FG", "0");

                trTranSales.Add("TR_SPECAL_LIST", new JArray());
                trTranSales.Add("TR_OFFER_SAVE", new JArray());
                trTranSales.Add("TR_COUPON_LIST", new JArray());

                JArray custInfoList = new JArray();
                trTranSales.Add("CustInfoList", custInfoList);
                JObject custInfo = new JObject();
                custInfoList.Add(custInfo);
                custInfo.Add("ANS_CD", "");
                custInfo.Add("ANS_DESC", "");
                custInfo.Add("CUST_CD", custCd);
                custInfo.Add("CUST_NM", dt.Rows[0]["full_name"].ToString());
                custInfo.Add("CUST_ABB", dt.Rows[0]["full_name"].ToString());
                custInfo.Add("BUSI_NO", "");    // 모름
                custInfo.Add("CEO_NM", dt.Rows[0]["full_name"].ToString());
                custInfo.Add("GROUP_PRICE_CD", "00");
                custInfo.Add("NATION_DIV", "V");
                custInfo.Add("CUST_ADDR", "");
                custInfo.Add("TEL_NO", "");
                custInfo.Add("CEL_NO", custCd);
                custInfo.Add("POINT_NO", dt.Rows[0]["point_no"].ToString());
                custInfo.Add("ABLE_POINT", availPoint);
                custInfo.Add("RESERVE_RATE", 1.0);
                custInfo.Add("POINT_PWD", "");
                custInfo.Add("CREDIT_TRADE_YN", "N");
                custInfo.Add("LOAN_TRADE_YN", "N");
                custInfo.Add("LOAN_AMT", "0");
                custInfo.Add("MISU_AMT", "0");
                custInfo.Add("DEAL_LIMIT_YN", "N");
                custInfo.Add("DEAL_LIMIT_AMT", "0");
                custInfo.Add("DEAL_AMT", "0");
                custInfo.Add("CUST_SECTOR", "P");
                custInfo.Add("SONATA_CD", "");

                trTranSales.Add("ItemDiscountTotal", 0.0);
                trTranSales.Add("ItemDiscountAmount", 0.0);
                trTranSales.Add("ItemEnuriAmount", 0.0);
                trTranSales.Add("ItemMCouponDiscountAmount", 0.0);
                trTranSales.Add("ItemMCouponDiscountCount", 0);
                trTranSales.Add("InfantAmount", 0.0);
                trTranSales.Add("InfantDiscountAmount", 0.0);
                trTranSales.Add("InfantSavePoint", 0.0);
                trTranSales.Add("GiftAmount", 0.0);
                trTranSales.Add("TenderMCouponCount", 0);
                trTranSales.Add("TenderTotalAmount", priceTotSaleUnit);
                trTranSales.Add("OpenCashDrawer", false);
                trTranSales.Add("GetOfferTotalDiscount", 0);
                trTranSales.Add("GetLPointCpn", new JArray());

                string trInfo     = JsonConvert.SerializeObject(trData);
                string utf8String = Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(trInfo));
                byte[] bytes      = Encoding.UTF8.GetBytes(utf8String);
                string base64     = Convert.ToBase64String(bytes);

                tranReq.Add("TR_DATA", base64);

                COM.WmsSocket socket = new COM.WmsSocket();
                JObject       result = socket.Connect(30001, wmsRequest);


                string reqInfo = JsonConvert.SerializeObject(wmsRequest);
                string retInfo = JsonConvert.SerializeObject(result);

                request        = new JsonRequest();
                logAction      = request.NewAction();
                logAction.proc = WebUtil.Values.PROC_SQL;
                sql.Clear();
                sql.Append("update tb_log_wms set req_info = #{req_info}, tr_info = #{tr_info}, ret_info = #{ret_info} ");
                sql.Append(" WHERE log_id = #{log_id} ");
                logAction.text = sql.ToString();
                logAction.param.Add("log_id", dtLog.Rows[0]["log_id"]);
                logAction.param.Add("req_info", reqInfo);
                logAction.param.Add("tr_info", trInfo);
                logAction.param.Add("ret_info", retInfo);

                client = new WebClient();
                client.Execute(request);


                this.Close();
            }
            else
            {
                //MessageBox.Show(client.message);
                XtraMessageBox.Show("Có lỗi xảy ra: \n" + client.message, "Lỗi");
            }
        }
Ejemplo n.º 21
0
        void Search()
        {
            treeList1.ClearNodes();

            JsonRequest request = new JsonRequest();

            ProcAction action1 = request.NewAction();

            action1.proc = "sql";
            //action1.text = "WITH RECURSIVE CTE AS ( ";
            //action1.text += "    SELECT * ";
            //action1.text += "	FROM hanbibase.tb_sys_menu ";
            //action1.text += "	WHERE menu_type = 'root' ";
            //action1.text += "	UNION ALL ";
            //action1.text += "	SELECT a.* ";
            //action1.text += "	FROM hanbibase.tb_sys_menu a ";
            //action1.text += "		INNER JOIN CTE b ON a.parent_id = b.menu_id ";
            //action1.text += ") ";
            //action1.text += "SELECT * FROM CTE";

            //action1.text = "select  * ";
            //action1.text += "from    (select * from hanbibase.tb_sys_menu ";
            //action1.text += "         order by parent_id, menu_id) products_sorted, ";
            //action1.text += "        (select @pv := '1') initialisation ";
            //action1.text += "where   find_in_set(parent_id, @pv) >= 0 ";
            //action1.text += "and     @pv := concat(@pv, ',', menu_id) ";

            action1.text  = "select * from tb_sys_menu A left join ";
            action1.text += " (select * from tb_sys_menu where menu_type = 'root' and use_yn = 'Y') B on A.parent_id = B.parent_id";
            action1.text += " where A.use_yn = 'Y' order by A.parent_id, A.menu_id asc";

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            DataTable dt = ds.Tables[0];

            treeList1.BeginUnboundLoad();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                MenuNodeTag tag = new MenuNodeTag();
                tag.stat    = "";
                tag.menu_id = dt.Rows[i]["menu_id"].ToString();
                int id = Convert.ToInt32(tag.menu_id);
                if (maxId < id)
                {
                    maxId = id;
                }
                tag.parent_id  = dt.Rows[i]["parent_id"] == System.DBNull.Value ? "" : dt.Rows[i]["parent_id"].ToString();
                tag.menu_name  = (string)dt.Rows[i]["menu_name"];
                tag.menu_type  = (string)dt.Rows[i]["menu_type"];
                tag.sort       = (int)dt.Rows[i]["sort"];
                tag.dll_name   = dt.Rows[i]["dll_name"] == System.DBNull.Value ? "" : dt.Rows[i]["dll_name"].ToString();
                tag.class_name = dt.Rows[i]["class_name"] == System.DBNull.Value ? "" : dt.Rows[i]["class_name"].ToString();
                tag.use_yn     = (string)dt.Rows[i]["use_yn"];
                tag.depth      = (int)dt.Rows[i]["depth"];
                tag.menu_group = (string)dt.Rows[i]["menu_group"];
                tag.close_yn   = (string)dt.Rows[i]["close_yn"];
                tag.open_yn    = (string)dt.Rows[i]["open_yn"];

                Dictionary <string, string> dic = CommonUtil.Converter.GetNameDictionary(tag.menu_name);

                TreeListNode parentNode = treeList1.FindNodeByFieldValue("id", tag.parent_id);

                TreeListNode node = treeList1.AppendNode(
                    new object[] { tag.menu_id, dic["ko"], dic["en"], dic["vi"], tag.use_yn },
                    parentNode, tag);
            }

            treeList1.EndUnboundLoad();

            treeList1.ExpandAll();

            if (treeList1.Nodes.Count > 0)
            {
                treeList1.FocusedNode = treeList1.Nodes[0];
            }
        }
Ejemplo n.º 22
0
        void Save()
        {
            JsonRequest request = new JsonRequest();

            ProcAction action = request.NewAction();

            action.proc = WebUtil.Values.PROC_SQL;

            StringBuilder sql = new StringBuilder();

            // New Group
            if (bolNewGroup)
            {
                if (String.IsNullOrEmpty(txtGroupId.Text) || HBConstant.checkExistID(HBConstant.TB_SYS_CODE_GRP, txtGroupId.FieldName, txtGroupId.Text) != HBConstant.NORMAL)
                {
                    //XtraMessageBox.Show("이미 존재하거나 비어있는 ID.", "성공");
                    XtraMessageBox.Show("Mã nhóm đang trống hoặc đã tồn tại.", "Lỗi");
                    return;
                }

                sql.Append("INSERT INTO " + HBConstant.TB_SYS_CODE_GRP);
                sql.Append("(grp_cd, grp_nm, sys_yn, use_yn, remark)");
                sql.Append(" VALUES (#{grp_cd}, #{grp_nm}, #{sys_yn}, #{use_yn}, #{remark}) ");

                action.text = sql.ToString();
                action.param.Add(txtGroupId.FieldName, txtGroupId.Text);
                action.param.Add(txtGroupName.FieldName, txtGroupName.Text);
                action.param.Add(chkSys.FieldName, chkSys.Value);
                action.param.Add(chkUse.FieldName, chkUse.Value);
                action.param.Add(txtRemark.FieldName, txtRemark.Text);
            }
            //Update Group
            else
            {
                sql.Append("UPDATE " + HBConstant.TB_SYS_CODE_GRP);
                sql.Append(" SET grp_nm = #{grp_nm}, sys_yn = #{sys_yn}, use_yn = #{use_yn}, remark = #{remark} ");
                sql.Append("WHERE grp_cd = #{grp_cd}");

                action.text = sql.ToString();
                action.param.Add(txtGroupName.FieldName, txtGroupName.Text);
                action.param.Add(chkSys.FieldName, chkSys.Value);
                action.param.Add(chkUse.FieldName, chkUse.Value);
                action.param.Add(txtRemark.FieldName, txtRemark.Text);
                action.param.Add(txtGroupId.FieldName, txtGroupId.Text);
            }

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            if (client.check)
            {
                //XtraMessageBox.Show("저장 했습니다.", "성공");
                XtraMessageBox.Show("Lưu thành công.", "Thông báo");
                Search();
            }
            else
            {
                //XtraMessageBox.Show("저장 실패: " + client.message, "실패");
                XtraMessageBox.Show("Có lỗi xảy ra: \n" + client.message, "Lỗi");
            }
        }
Ejemplo n.º 23
0
        private void DisplayOrders(string status)
        {
            strStatus = status;
            if (gridDashboard.DataSource != null)
            {
                gridDashboard.DataSource = null;
            }
            InitGridOrders(status);

            JsonRequest request = new JsonRequest();
            ProcAction  action  = request.NewAction();

            action.proc = WebUtil.Values.PROC_SQL;

            StringBuilder sql = new StringBuilder();

            sql.Append("SELECT A.ord_no, A.cust_id, A.full_name, A.mobile_no, A.tel_no,");
            sql.Append(" A.pay_tp, C.pay_nm, A.ship_addr, A.price_total, DATE_FORMAT(A.up_dt, '%Y-%m-%d') AS up_dt, DATE_FORMAT(A.in_dt, '%Y-%m-%d') AS in_dt,");
            switch (strStatus)
            {
            case C_NEW:
                sql.Append(" 'New' AS ord_status");
                break;

            case C_PICKING:
                sql.Append(" D.pick_no, D.pick_sts, E.pick_sts_nm");
                break;

            case C_DELIVERING:
                sql.Append(" D.delv_no, 'Delivering' AS ord_status");
                break;

            case C_WAITING:
                sql.Append(" 'Waiting' AS ord_status");
                break;
            }

            sql.Append(" , CASE ");
            sql.Append("  WHEN TIMEDIFF(NOW(), A.up_dt) <= #{time_level_2} THEN \"1\" ");
            sql.Append("  WHEN TIMEDIFF(NOW(), A.up_dt) > #{time_level_2} AND TIMEDIFF(NOW(), A.up_dt) <= #{time_level_3} THEN \"2\"");
            sql.Append("  WHEN TIMEDIFF(NOW(), A.up_dt) > #{time_level_3} THEN \"3\"");
            sql.Append(" END AS ord_level");

            sql.Append(" FROM tb_so_order A LEFT JOIN tb_ma_pickup_loc B ON A.loc_cd = B.loc_cd");
            sql.Append(" LEFT JOIN (SELECT cd as pay_tp, cd_nm as pay_nm FROM tb_sys_code WHERE grp_cd = 'PAY_TP') C ON A.pay_tp = C.pay_tp");

            switch (strStatus)
            {
            case C_NEW:
                sql.Append(" WHERE A.pick_ord_yn ='N' AND A.pick_yn = 'N' AND A.delv_ord_yn = 'N' AND A.delv_yn = 'N' AND A.stop_yn = 'N'");
                break;

            case C_PICKING:
                sql.Append(" LEFT JOIN tb_so_pick D ON A.ord_id = D.ord_id AND A.ord_no = D.ord_no");
                sql.Append(" LEFT JOIN (SELECT cd as pick_cd, cd_nm as pick_sts_nm FROM tb_sys_code WHERE grp_cd = 'PICKUP_STATUS') E ON D.pick_sts = E.pick_cd");
                sql.Append(" WHERE A.pick_ord_yn ='Y' AND A.pick_yn = 'N' AND A.delv_ord_yn = 'N' AND A.delv_yn = 'N' AND A.stop_yn = 'N'");
                break;

            case C_DELIVERING:
                sql.Append(" LEFT JOIN tb_so_delv D ON A.ord_id = D.ord_id AND A.ord_no = D.ord_no");
                sql.Append(" WHERE A.pick_ord_yn ='Y' AND A.pick_yn = 'Y' AND A.delv_ord_yn = 'Y' AND A.delv_yn = 'N' AND A.stop_yn = 'N'");
                break;

            case C_WAITING:
                sql.Append(" WHERE A.pick_ord_yn ='Y' AND A.pick_yn = 'Y' AND A.delv_yn = 'N' AND A.stop_yn = 'N'");
                break;
            }

            if (!String.IsNullOrEmpty(COM.UserInfo.LocCode))
            {
                sql.Append(" AND A.loc_cd = #{loc_cd}");
                action.param.Add("loc_cd", COM.UserInfo.LocCode);
            }
            action.param.Add("time_level_2", "00:03:00");
            action.param.Add("time_level_3", "00:05:00");

            sql.Append(" ORDER BY in_dt asc");

            action.text = sql.ToString();

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            gridDashboard.DataSource = ds.Tables[0];
            gridDashboard.Refresh();

            switch (status)
            {
            case C_NEW:
                // Update New numbers
                if (ds.Tables[0].Rows.Count != intNew)
                {
                    intNew        = ds.Tables[0].Rows.Count;
                    labelNew.Text = intNew.ToString();
                }
                break;

            case C_PICKING:
                // Update Picking numbers
                if (ds.Tables[0].Rows.Count != intPicking)
                {
                    intPicking        = ds.Tables[0].Rows.Count;
                    labelPicking.Text = intPicking.ToString();
                }
                break;

            case C_DELIVERING:
                // Update Delivering numbers
                if (ds.Tables[0].Rows.Count != intDelivering)
                {
                    intDelivering        = ds.Tables[0].Rows.Count;
                    labelDelivering.Text = intDelivering.ToString();
                }
                break;

            case C_WAITING:
                // Update Waiting numbers
                if (ds.Tables[0].Rows.Count != intDelivering)
                {
                    intWaiting        = ds.Tables[0].Rows.Count;
                    labelWaiting.Text = intWaiting.ToString();
                }
                break;
            }
        }
Ejemplo n.º 24
0
        /*
         * flagOrder:
         *              1: Orders
         *              2: Picking
         *              3: Delivering
         *
         */
        public static bool CheckOrders(string flagOrder)
        {
            bool result = false;

            JsonRequest request = new JsonRequest();

            ProcAction action = request.NewAction();

            action.proc  = "sql";
            action.text  = "SELECT A.ord_no, B.pick_no, C.delv_no, A.pick_ord_yn, A.pick_yn,";
            action.text += " A.delv_ord_yn, A.delv_yn, A.stop_yn, B.pick_sts, C.delv_yn";
            action.text += " FROM tb_so_order A LEFT JOIN tb_so_pick B ON A.ord_no = B.ord_no ";
            action.text += " LEFT JOIN tb_so_delv C ON A.ord_no = C.ord_no AND A.delv_yn = C.delv_yn";
            action.text += " WHERE A.ord_no = #{ord_no}";
            action.table = "0";

            action.param.Add("ord_no", ord_no);

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            if (ds == null)
            {
                return(result);
            }

            DataTable dt = ds.Tables["0"];

            if (dt.Rows.Count != 1)
            {
                return(result);
            }

            string pickOrdYn = dt.Rows[0]["pick_ord_yn"].ToString();
            string pickYn    = dt.Rows[0]["pick_yn"].ToString();
            string delvOrdYn = dt.Rows[0]["delv_ord_yn"].ToString();
            string delvYn    = dt.Rows[0]["delv_yn"].ToString();
            string stopYn    = dt.Rows[0]["pick_ord_yn"].ToString();
            string pickSts   = dt.Rows[0]["pick_sts"].ToString();
            string pickNo    = dt.Rows[0]["pick_no"].ToString();
            string delvNo    = dt.Rows[0]["delv_no"].ToString();

            switch (flagOrder)
            {
            case "1":
                // Orders have not been picked
                break;

            case "2":
                // Picking is already to finished
                if (pickYn == "Y" && pickSts == "done" && delvOrdYn == "N" && stopYn == "N")
                {
                    if (XtraMessageBox.Show("Đơn lấy hàng " + pickNo + " đã hoàn thành. \nBạn có muốn thực hiện giao hàng cho đơn đặt hàng này không?", "Xác nhận", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        if (MakeDelivery())
                        {
                            result = true;
                        }
                    }
                }
                break;

            case "3":
                // Delivering is already to finished
                if (delvOrdYn == "Y" && delvYn == "N" && stopYn == "N")
                {
                    if (XtraMessageBox.Show("Đơn giao hàng " + delvNo + " chưa hoàn thành. \nBạn có muốn đánh dấu là đã giao hàng thành công hay không?", "Xác nhận", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        result = true;
                    }
                }
                break;
            }
            ;

            return(result);
        }
Ejemplo n.º 25
0
        void btnDeleteCode_Click(object sender, System.EventArgs e)
        {
            if (bolNewGroup)
            {
                //XtraMessageBox.Show("새 코드 그룹을 저장하십시오.", "성공");
                XtraMessageBox.Show("Một nhóm mới đang được thêm, hãy thực hiện lưu nhóm.", "Thông báo");
                return;
            }

            if (gridViewCode.RowCount == 0)
            {
                return;
            }

            if (bolNewCode)
            {
                gridViewCode.DeleteRow(gridViewCode.FocusedRowHandle);
                bolNewCode = false;
                return;
            }

            //if (XtraMessageBox.Show("정말로 삭제 하시겠습니까?", "확인", MessageBoxButtons.OKCancel) == DialogResult.OK)
            if (XtraMessageBox.Show("Bạn có thực sự muốn xóa không?", "Xác nhận", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                JsonRequest request = new JsonRequest();
                ProcAction  action  = request.NewAction();
                action.proc = WebUtil.Values.PROC_SQL;

                StringBuilder sql = new StringBuilder();
                DataRowView   row;
                string        cd     = String.Empty;
                string        grp_cd = String.Empty;

                if (gridViewCode.GetSelectedRows().Length > 0)
                {
                    row    = (DataRowView)gridViewCode.GetRow(gridViewCode.GetSelectedRows()[0]);
                    cd     = row.Row[0].ToString();
                    grp_cd = txtGroupId.Text;
                }

                sql.Append("DELETE FROM " + HBConstant.TB_SYS_CODE);
                sql.Append(" WHERE cd = #{cd} and grp_cd = #{grp_cd}");

                action.text = sql.ToString();
                action.param.Add("cd", cd);
                action.param.Add("grp_cd", grp_cd);

                WebClient client = new WebClient();
                DataSet   ds     = client.Execute(request);

                if (client.check)
                {
                    //XtraMessageBox.Show("삭제 했습니다.", "성공");
                    XtraMessageBox.Show("Xóa thành công.", "Thông báo");
                    RefreshCode((int)gridViewCodeGroup.GetSelectedRows()[0]);
                }
                else
                {
                    //XtraMessageBox.Show("삭제 실패: " + client.message, "실패");
                    XtraMessageBox.Show("Có lỗi xảy ra: \n" + client.message, "Lỗi");
                }
            }
        }
Ejemplo n.º 26
0
        private static bool MakeDelivery()
        {
            string delvNo = getNextNo("DL");

            if (String.IsNullOrEmpty(delvNo))
            {
                return(false);
            }

            JsonRequest   request = new JsonRequest();
            StringBuilder sql     = new StringBuilder();

            // Update Order
            ProcAction updateOrder = request.NewAction();

            updateOrder.proc = WebUtil.Values.PROC_SQL;

            sql.Append("UPDATE tb_so_order");
            sql.Append(" SET delv_ord_yn = #{delv_ord_yn}, up_id = #{up_id}, up_dt = CURRENT_TIMESTAMP");
            sql.Append(" WHERE ord_no = #{ord_no}");

            updateOrder.text = sql.ToString();
            updateOrder.param.Add("delv_ord_yn", "Y");
            updateOrder.param.Add("up_id", COM.UserInfo.UserID);
            updateOrder.param.Add("ord_no", ord_no);

            // Create Delivery
            ProcAction insertDelv = request.NewAction();

            insertDelv.proc = WebUtil.Values.PROC_SQL;

            sql.Clear();
            sql.Append("INSERT INTO tb_so_delv");
            sql.Append(" (delv_id, delv_no, ord_id, ord_no, loc_cd,");
            sql.Append(" cust_id, full_name, email, mobile_no, tel_no,");
            sql.Append(" ord_dt, delv_dt, delv_tp, pay_tp, pay_info, ship_post_cd, ship_addr, ship_addr_dtl,");
            sql.Append(" price_total, price_delv, price_point, price_card, price_real, delv_yn, in_id, in_dt)");

            sql.Append(" SELECT ord_id, #{delv_no}, ord_id, #{ord_no}, loc_cd,");
            sql.Append(" cust_id, full_name, email, mobile_no, tel_no,");
            sql.Append(" ord_dt, delv_dt, delv_tp, pay_tp, pay_info, ship_post_cd, ship_addr, ship_addr_dtl, ");
            sql.Append(" price_total, price_delv, price_point, price_card, price_real, delv_yn, #{in_id}, CURRENT_TIMESTAMP");
            sql.Append(" FROM tb_so_order WHERE ord_no = #{ord_no}");

            insertDelv.text = sql.ToString();
            insertDelv.param.Add("delv_no", delvNo);                                                     // delv_no
            insertDelv.param.Add("ord_no", ord_no);                                                      // ord_no
            insertDelv.param.Add("in_id", COM.UserInfo.UserID);                                          // in_id

            // Create Delivery detail
            ProcAction insertDelvDtl = request.NewAction();

            insertDelvDtl.proc = WebUtil.Values.PROC_SQL;

            sql.Clear();
            sql.Append("INSERT INTO tb_so_delv_dtl");
            sql.Append(" (delv_id, delv_no, delv_seq, ord_dtl_id, ord_id,");
            sql.Append(" ord_no, ord_seq, loc_cd, prod_cd, prod_nm,");
            sql.Append(" unit, ord_qty, unit_price, unit_sale_price,");
            sql.Append(" unit_delv_price, in_id, in_dt)");
            sql.Append(" SELECT ord_id, #{delv_no}, ord_seq, ord_dtl_id, ord_id,");
            sql.Append(" ord_no, ord_seq, loc_cd, prod_cd, prod_nm,");
            sql.Append(" unit, ord_qty, unit_price, unit_sale_price,");
            sql.Append(" unit_delv_price, #{in_id}, CURRENT_TIMESTAMP");
            sql.Append(" FROM tb_so_order_dtl WHERE ord_no = #{ord_no}");

            insertDelvDtl.text = sql.ToString();
            insertDelvDtl.param.Add("delv_no", delvNo);                                           // delv_no
            insertDelvDtl.param.Add("in_id", COM.UserInfo.UserID);                                // in_id
            insertDelvDtl.param.Add("ord_no", ord_no);

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            if (client.check)
            {
                //XtraMessageBox.Show("피킹 성공.", "성공");
                //XtraMessageBox.Show("Sẵn sàng giao hàng.", "Thông báo");

                COM.PrintFormats.PrintDelivery(ord_no);
                return(true);
            }
            else
            {
                //XtraMessageBox.Show("피킹에 실패: " + client.message, "실패");
                XtraMessageBox.Show("Có lỗi xảy ra: \n" + client.message, "Lỗi");
            }

            return(false);
        }
Ejemplo n.º 27
0
        public static void PrintDelivery(string ordNo)
        {
            JsonRequest request = new JsonRequest();

            ProcAction headerAction = request.NewAction();

            headerAction.proc = WebUtil.Values.PROC_SQL;
            StringBuilder sql = new StringBuilder();

            sql.Append("SELECT A.delv_id, A.delv_no, A.ord_id, A.ord_no, A.loc_cd,");
            sql.Append(" B.loc_nm, A.cust_id, A.full_name, DATE_FORMAT(A.ord_dt, '%Y-%m-%d %T') ord_dt, A.email, A.mobile_no,");
            sql.Append(" A.tel_no, A.delv_tp, D.delv_nm, DATE_FORMAT(A.delv_dt, '%Y-%m-%d %H:%i') delv_dt, A.pay_tp, C.pay_nm, A.pay_info, A.ship_post_cd,");
            sql.Append(" A.ship_addr, A.ship_addr_dtl, A.price_total, A.price_delv, A.price_point, A.price_card, A.price_real, A.price_cancel,");
            sql.Append(" (A.price_total + A.price_delv - A.price_real - A.price_point - A.price_card - A.price_event_point - A.price_coupon) AS price_dc,");       // price_dc
            sql.Append(" A.delv_yn");
            sql.Append(" FROM tb_so_delv A");
            sql.Append(" LEFT JOIN tb_ma_pickup_loc B ON A.loc_cd = B.loc_cd ");
            sql.Append(" LEFT JOIN (SELECT cd as pay_tp, cd_nm as pay_nm FROM tb_sys_code WHERE grp_cd = 'PAY_TP') C ON A.pay_tp = C.pay_tp ");
            sql.Append(" LEFT JOIN (SELECT cd as delv_tp, cd_nm as delv_nm FROM tb_sys_code WHERE grp_cd = 'DELV_TP') D ON A.delv_tp = D.delv_tp ");
            sql.Append(" WHERE A.ord_no = #{ord_no}");
            headerAction.text = sql.ToString();
            headerAction.param.Add("ord_no", ordNo);

            ProcAction detailAction = request.NewAction();

            detailAction.proc = WebUtil.Values.PROC_SQL;
            sql.Clear();
            sql.Append("SELECT A.delv_dtl_id, A.delv_id, A.delv_no, A.delv_seq, A.prod_cd,");
            sql.Append(" B.prod_nm_ko, B.prod_nm_en, B.prod_nm, A.unit, A.ord_qty, A.pick_qty,");
            sql.Append(" A.unit_price, A.unit_sale_price, A.unit_delv_price");
            sql.Append(" FROM tb_so_delv_dtl A ");
            sql.Append(" LEFT JOIN tb_ma_product B ON A.prod_cd = B.prod_cd ");
            sql.Append(" WHERE A.ord_no = #{ord_no}");
            sql.Append(" ORDER BY A.ord_dtl_id");
            detailAction.text = sql.ToString();
            detailAction.param.Add("ord_no", ordNo);

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            DataTable dtHeader = ds.Tables[0];
            DataTable dtDtl    = ds.Tables[1];

            string delvType       = dtHeader.Rows[0]["delv_tp"].ToString();
            string payType        = dtHeader.Rows[0]["pay_tp"].ToString();
            double priceTotal     = Double.Parse(dtHeader.Rows[0]["price_total"].ToString());
            string strPriceTotal  = priceTotal == 0 ? "0" : String.Format("{0:#,###}", priceTotal);
            double pricePoint     = Double.Parse(dtHeader.Rows[0]["price_point"].ToString());
            string strPricePoint  = pricePoint == 0 ? "0" : String.Format("{0:#,###}", pricePoint);
            double priceCard      = Double.Parse(dtHeader.Rows[0]["price_card"].ToString());
            string strPriceCard   = priceCard == 0 ? "0" : String.Format("{0:#,###}", priceCard);
            double priceCoupon    = 0;
            string strPriceCoupon = priceCoupon == 0 ? "0" : String.Format("{0:#,###}", priceCoupon);
            double priceDelv      = Double.Parse(dtHeader.Rows[0]["price_delv"].ToString());
            string strPriceDelv   = priceDelv == 0 ? "0" : String.Format("{0:#,###}", priceDelv);
            double priceReal      = Double.Parse(dtHeader.Rows[0]["price_real"].ToString());
            string strPriceReal   = priceReal == 0 ? "0" : String.Format("{0:#,###}", priceReal);
            double priceAll       = priceReal - priceDelv;
            string strPriceAlll   = priceAll == 0 ? "0" : String.Format("{0:#,###}", priceAll);

            double priceCancel    = Double.Parse(dtHeader.Rows[0]["price_cancel"].ToString());
            string strPriceCancel = priceCancel == 0 ? "0" : String.Format("{0:#,###}", priceCancel);
            double priceDC        = Double.Parse(dtHeader.Rows[0]["price_dc"].ToString());
            string strPriceDC     = priceDC == 0 ? "0" : String.Format("{0:#,###}", priceDC);

            PrintDocument doc = new PrintDocument();

            doc.PrinterSettings.PrinterName = COM.RawPrinterHelper.printerName;
            doc.PrintPage += new PrintPageEventHandler(doc_PrintPage);

            try
            {
                string str = "";

                if (delvType == "D")
                {
                    str  = "Hoa don (Khach hang luu tru)\n";
                    str += "영수증(고객보관용)\n";
                }
                else
                {
                    str  = "Bien lai don dat hang (Khach hang luu tru)\n";
                    str += "픽업 주문 영수증(고객보관용)\n";
                }
                str += "------------------------------------------\n";
                str += "Cua hang/매장명 : " + COM.CommonUtils.RemoveDiacritics(COM.UserInfo.LocName) + "\n";
                str += "Dia chi/매장 주소 : " + COM.CommonUtils.RemoveDiacritics(COM.UserInfo.LocAddr) + "\n";
                str += "SDT cua hang/매장 전화 : " + COM.CommonUtils.RemoveDiacritics(COM.UserInfo.LocTelNo) + "\n";
                str += "------------------------------------------\n";
                str += "Ma sp              So luong       Gia tien\n";
                str += "------------------------------------------\n";

                for (int i = 0; i < dtDtl.Rows.Count; i++)
                {
                    string procNmKo = COM.CommonUtils.RemoveDiacritics(dtDtl.Rows[i]["prod_nm_ko"].ToString());
                    str += procNmKo + "\n";
                    string procNm = COM.CommonUtils.RemoveDiacritics(dtDtl.Rows[i]["prod_nm"].ToString());
                    str += procNm + "\n";
                    string prodCd = dtDtl.Rows[i]["prod_cd"].ToString();
                    //double qty = Double.Parse(dtDtl.Rows[i]["ord_qty"].ToString());
                    double qty    = Double.Parse(dtDtl.Rows[i]["pick_qty"].ToString());
                    string ordQty = String.Format("{0:#,###}", qty);
                    double amt    = Double.Parse(dtDtl.Rows[i]["unit_sale_price"].ToString());
                    string sumAmt = String.Format("{0:#,###}", (amt * qty));

                    str += prodCd.PadRight(17, ' ') + ordQty.PadLeft(10, ' ') + sumAmt.PadLeft(15, ' ') + "\n";
                }
                str += "------------------------------------------\n";
                str += "So tien sp/상품금액 : " + strPriceTotal.PadLeft(20, ' ') + "\n";
                if (strPriceDC != "0")
                {
                    str += "Giam gia/할인 : " + strPriceDC.PadLeft(26, ' ') + "\n";
                }
                if (strPricePoint != "0")
                {
                    str += "Giam bang diem/포인트 : " + strPricePoint.PadLeft(18, ' ') + "\n";
                }
                if (strPriceCard != "0")
                {
                    str += "Giam bang voucher/상품권 : " + strPriceCard.PadLeft(15, ' ') + "\n";
                }
                if (strPriceCoupon != "0")
                {
                    str += "Giam gia coupon/쿠폰 : " + strPriceCoupon.PadLeft(19, ' ') + "\n";
                }
                str += "Tong so tien tt/총결제금액 : " + strPriceAlll.PadLeft(13, ' ') + "\n";
                if (strPriceDelv != "0")
                {
                    str += "Phi van chuyen/배달비 : " + strPriceDelv.PadLeft(18, ' ') + "\n";
                }
                str += "So tien tt cuoi cung/합계 : " + strPriceReal.PadLeft(14, ' ') + "\n";
                if (strPriceCancel != "0")
                {
                    str += "So tien tra lai KH/고객 반환 : " + strPriceCancel.PadLeft(11, ' ') + "\n";
                }
                if (payType == "offline")
                {
                    str += "Thanh toan khong thanh cong/결제 미완료\n";
                }
                else
                {
                    str += "Thanh toan thanh cong/결제 완료\n";
                }
                str += "------------------------------------------\n";
                str += "■ Thong tin giao hang\n";
                str += "Phuong thuc tt/결제수단 : " + (dtHeader.Rows[0]["pay_info"].ToString() == "COD"? "Tien mat" : "The VISA") + "\n";
                str += "So don hang/주문번호 : " + ordNo + "\n";
                str += "Thoi gian dat/주문 : " + dtHeader.Rows[0]["ord_dt"].ToString() + "\n";
                str += "Nguoi nhan hang/수취인 : " + COM.CommonUtils.RemoveDiacritics(dtHeader.Rows[0]["full_name"].ToString()) + "\n";
                str += "So dien thoai/전화 번호 : " + dtHeader.Rows[0]["mobile_no"].ToString() + "\n";
                str += "Thoi gian giao/배송시간 : " + dtHeader.Rows[0]["delv_dt"].ToString() + "\n";
                str += "Dia chi/주소 : " + COM.CommonUtils.RemoveVietnameseChar(COM.CommonUtils.RemoveDiacritics(dtHeader.Rows[0]["ship_addr"].ToString())) + "\n";
                str += COM.CommonUtils.RemoveVietnameseChar(COM.CommonUtils.RemoveDiacritics(dtHeader.Rows[0]["ship_addr_dtl"].ToString())) + "\n";
                str += "                                                                                                                  \n";
                //str += "                                                                                                                  \n";
                COM.RawPrinterHelper.SendStringToPrinter(COM.RawPrinterHelper.printerName, str);
                COM.RawPrinterHelper.PrintBarcode("&" + ordNo);
                doc.Print();


                if (delvType == "D")
                {
                    str  = "Hoa don (Nha cung cap luu tru)\n";
                    str += "영수증(공급사보관용)\n";
                }
                else
                {
                    str  = "Bien lai don hang pickup (Nha cung cap luu tru)\n";
                    str += "픽업 주문 영수증(공급사보관용)\n";
                }
                str += "------------------------------------------\n";
                str += "Cua hang/매장명 : " + COM.CommonUtils.RemoveDiacritics(COM.UserInfo.LocName) + "\n";
                str += "Dia chi/매장 주소 : " + COM.CommonUtils.RemoveDiacritics(COM.UserInfo.LocAddr) + "\n";
                str += "SDT cua hang/매장 전화 : " + COM.CommonUtils.RemoveDiacritics(COM.UserInfo.LocTelNo) + "\n";
                str += "------------------------------------------\n";
                str += "Ma sp              So luong       Gia tien\n";
                str += "------------------------------------------\n";

                for (int i = 0; i < dtDtl.Rows.Count; i++)
                {
                    string procNmKo = COM.CommonUtils.RemoveDiacritics(dtDtl.Rows[i]["prod_nm_ko"].ToString());
                    str += procNmKo + "\n";
                    string procNm = COM.CommonUtils.RemoveDiacritics(dtDtl.Rows[i]["prod_nm"].ToString());
                    str += procNm + "\n";
                    string prodCd = dtDtl.Rows[i]["prod_cd"].ToString();
                    //double qty = Double.Parse(dtDtl.Rows[i]["ord_qty"].ToString());
                    double qty    = Double.Parse(dtDtl.Rows[i]["pick_qty"].ToString());
                    string ordQty = String.Format("{0:#,###}", qty);
                    double amt    = Double.Parse(dtDtl.Rows[i]["unit_sale_price"].ToString());
                    string sumAmt = String.Format("{0:#,###}", (amt * qty));

                    str += prodCd.PadRight(17, ' ') + ordQty.PadLeft(10, ' ') + sumAmt.PadLeft(15, ' ') + "\n";
                }
                str += "------------------------------------------\n";
                str += "So tien sp/상품금액 : " + strPriceTotal.PadLeft(20, ' ') + "\n";
                if (strPriceDC != "0")
                {
                    str += "Giam gia/할인 : " + strPriceDC.PadLeft(26, ' ') + "\n";
                }
                if (strPricePoint != "0")
                {
                    str += "Giam bang diem/포인트 : " + strPricePoint.PadLeft(18, ' ') + "\n";
                }
                if (strPriceCard != "0")
                {
                    str += "Giam bang voucher/상품권 : " + strPriceCard.PadLeft(15, ' ') + "\n";
                }
                if (strPriceCoupon != "0")
                {
                    str += "Giam gia coupon/쿠폰 : " + strPriceCoupon.PadLeft(19, ' ') + "\n";
                }
                str += "Tong so tien tt/총결제금액 : " + strPriceAlll.PadLeft(13, ' ') + "\n";
                if (strPriceDelv != "0")
                {
                    str += "Phi van chuyen/배달비 : " + strPriceDelv.PadLeft(18, ' ') + "\n";
                }
                str += "So tien tt cuoi cung/합계 : " + strPriceReal.PadLeft(14, ' ') + "\n";
                if (strPriceCancel != "0")
                {
                    str += "So tien tra lai KH/고객 반환 : " + strPriceCancel.PadLeft(11, ' ') + "\n";
                }
                if (payType == "offline")
                {
                    str += "Thanh toan khong thanh cong/결제 미완료\n";
                }
                else
                {
                    str += "Thanh toan thanh cong/결제 완료\n";
                }
                str += "------------------------------------------\n";
                str += "■ Thong tin giao hang\n";
                str += "Phuong thuc tt/결제수단 : " + (dtHeader.Rows[0]["pay_info"].ToString() == "COD" ? "Tien mat" : "The VISA") + "\n";
                str += "So don hang/주문번호 : " + ordNo + "\n";
                str += "Ngay gio dat/주문 : " + dtHeader.Rows[0]["ord_dt"].ToString() + "\n";
                str += "Nguoi nhan hang/수취인 : " + COM.CommonUtils.RemoveDiacritics(dtHeader.Rows[0]["full_name"].ToString()) + "\n";
                str += "So dien thoai/전화 번호 : " + dtHeader.Rows[0]["mobile_no"].ToString() + "\n";
                str += "Thoi gian giao/배송시간 : " + dtHeader.Rows[0]["delv_dt"].ToString() + "\n";
                str += "Dia chi/주소 : " + COM.CommonUtils.RemoveVietnameseChar(COM.CommonUtils.RemoveDiacritics(dtHeader.Rows[0]["ship_addr"].ToString())) + "\n";
                str += COM.CommonUtils.RemoveVietnameseChar(COM.CommonUtils.RemoveDiacritics(dtHeader.Rows[0]["ship_addr_dtl"].ToString())) + "\n";
                str += "                                                                                                                  \n";
                //str += "                                                                                                                  \n";
                COM.RawPrinterHelper.SendStringToPrinter(COM.RawPrinterHelper.printerName, str);
                COM.RawPrinterHelper.PrintBarcode("&" + ordNo);
                doc.Print();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Print Receipt");
            }
        }
Ejemplo n.º 28
0
        void Save()
        {
            JsonRequest request = new JsonRequest();

            ProcAction action = request.NewAction();

            action.proc = WebUtil.Values.PROC_SQL;

            StringBuilder sql = new StringBuilder();

            // Insert New User
            if (bolNewUser)
            {
                if (String.IsNullOrEmpty(txtUserID.Text) || HBConstant.checkExistID(HBConstant.TB_SYS_USER, txtUserID.FieldName, txtUserID.Text) != HBConstant.NORMAL)
                {
                    //XtraMessageBox.Show("이미 존재하거나 비어있는 ID.", "성공");
                    XtraMessageBox.Show("Mã người dùng đang trống hoặc đã tồn tại", "Lỗi");
                    return;
                }

                sql.Append(" INSERT INTO " + HBConstant.TB_SYS_USER);
                sql.Append(" (user_id, user_nm, user_pw, loc_cd, role_id, use_yn, in_id, in_dt)");
                //sql.Append(" VALUES (#{user_id}, #{user_nm}, TO_BASE64(#{user_pw}), #{loc_cd}, #{use_yn}, #{in_id}, CURRENT_TIMESTAMP)");
                sql.Append(" VALUES (#{user_id}, #{user_nm}, #{user_pw}, #{loc_cd}, #{role_id}, #{use_yn}, #{in_id}, CURRENT_TIMESTAMP)");

                action.text = sql.ToString();

                action.param.Add(txtUserID.FieldName, txtUserID.Text);
                action.param.Add(txtUserName.FieldName, txtUserName.Text);
                action.param.Add(txtPassword.FieldName, COM.AES256.AESEncrypt256(txtPassword.Text));

                action.param.Add(popLocation.FieldName, popLocation.Text);
                action.param.Add(cbRole.FieldName, cbRole.Value);
                action.param.Add(chkUse.FieldName, chkUse.Value);
                action.param.Add(HBConstant.C_IN_ID, COM.UserInfo.UserID);
            }
            //Update User
            else
            {
                sql.Append("UPDATE " + HBConstant.TB_SYS_USER);
                //sql.Append(" SET user_nm = #{user_nm}, user_pw = TO_BASE64(#{user_pw}), loc_cd = #{loc_cd}, use_yn = #{use_yn}, up_id = #{up_id}, up_dt = CURRENT_TIMESTAMP ");
                sql.Append(" SET user_nm = #{user_nm}, user_pw = #{user_pw}, loc_cd = #{loc_cd}, role_id = #{role_id}, use_yn = #{use_yn}, up_id = #{up_id}, up_dt = CURRENT_TIMESTAMP ");
                sql.Append(" WHERE user_id = #{user_id}");

                action.text = sql.ToString();
                action.param.Add(txtUserName.FieldName, txtUserName.Text);
                action.param.Add(txtPassword.FieldName, COM.AES256.AESEncrypt256(txtPassword.Text));

                action.param.Add(popLocation.FieldName, popLocation.Text);
                action.param.Add(cbRole.FieldName, cbRole.Value);
                action.param.Add(chkUse.FieldName, chkUse.Value);
                action.param.Add(HBConstant.C_UP_ID, COM.UserInfo.UserID);
                action.param.Add(txtUserID.FieldName, txtUserID.Text);
            }

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            if (client.check)
            {
                //XtraMessageBox.Show("저장 했습니다.", "성공");
                XtraMessageBox.Show("Lưu thành công.", "Thông báo");
                Search();
            }
            else
            {
                //XtraMessageBox.Show("저장 실패: " + client.message, "실패");
                XtraMessageBox.Show("Có lỗi xảy ra: \n" + client.message, "Lỗi");
            }
        }
Ejemplo n.º 29
0
        public static void PrintDailyFinish(DevExpress.XtraGrid.Views.Grid.GridView gridView, string startDate, string endDate)
        {
            int    selRow    = gridView.FocusedRowHandle;
            string locCd     = gridView.GetRowCellValue(selRow, "loc_cd").ToString();
            string locNm     = gridView.GetRowCellValue(selRow, "loc_nm").ToString();
            string startTime = startDate;
            string endTime   = endDate;
            string openTime  = String.Empty;
            string closeTime = String.Empty;
            string storeCd   = String.Empty;

            // Get market infor
            JsonRequest request = new JsonRequest();

            ProcAction action = request.NewAction();

            action.proc = WebUtil.Values.PROC_SQL;

            StringBuilder sql = new StringBuilder();

            sql.Append(" SELECT id, title, open_at, close_at, store_cd, pos_no FROM kmarket.markets ");
            sql.Append(" WHERE id = #{loc_cd} ");

            action.param.Add("loc_cd", locCd);

            action.text = sql.ToString();

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            if (client.check)
            {
                DataTable dt = ds.Tables[0];
                openTime  = dt.Rows[0]["open_at"].ToString();
                closeTime = dt.Rows[0]["close_at"].ToString();
                storeCd   = dt.Rows[0]["store_cd"].ToString();
            }
            else
            {
                MessageBox.Show(client.message, "Lỗi");
                return;
            }

            double totalAmount   = Double.Parse(gridView.GetRowCellValue(selRow, "total_amt_real").ToString());
            double paymentAmount = Double.Parse(gridView.GetRowCellValue(selRow, "total_amt_payment").ToString());
            double returnAmount  = Double.Parse(gridView.GetRowCellValue(selRow, "total_amt_return").ToString());
            double gapAmount     = Double.Parse(gridView.GetRowCellValue(selRow, "total_amt_gap").ToString());

            double delvAmount       = Double.Parse(gridView.GetRowCellValue(selRow, "total_amt_delv").ToString());
            double dcAmount         = Double.Parse(gridView.GetRowCellValue(selRow, "total_amt_dc").ToString());
            double pointAmount      = Double.Parse(gridView.GetRowCellValue(selRow, "total_amt_point").ToString());
            double voucherAmount    = Double.Parse(gridView.GetRowCellValue(selRow, "total_amt_voucher").ToString());
            double couponAmount     = 0;
            double eventPointAmount = 0;
            double productAmount    = Double.Parse(gridView.GetRowCellValue(selRow, "total_amt").ToString());

            double cardAmount = Double.Parse(gridView.GetRowCellValue(selRow, "total_amt_card").ToString());
            double atmAmount  = Double.Parse(gridView.GetRowCellValue(selRow, "total_amt_atm").ToString());
            double codAmount  = Double.Parse(gridView.GetRowCellValue(selRow, "total_amt_cod").ToString());

            double itemAmount    = productAmount + delvAmount;
            string strItemAmount = itemAmount == 0 ? "0" : String.Format("{0:#,###}", itemAmount);
            string strItemReturn = returnAmount == 0 ? "0" : String.Format("{0:#,###}", returnAmount);
            double totalPay      = itemAmount - returnAmount;
            string strItemTotal  = totalPay == 0 ? "0" : String.Format("{0:#,###}", totalPay);

            double cashAmount       = codAmount;
            double creditCardAmount = atmAmount + cardAmount;

            if (returnAmount > 0 && cashAmount > returnAmount)
            {
                cashAmount = cashAmount - returnAmount;
            }
            else if (returnAmount > 0 && creditCardAmount > returnAmount)
            {
                creditCardAmount = creditCardAmount - returnAmount;
            }

            string strCash    = cashAmount == 0 ? "0" : String.Format("{0:#,###}", cashAmount);
            string strCard    = creditCardAmount == 0 ? "0" : String.Format("{0:#,###}", creditCardAmount);
            string strDelv    = delvAmount == 0 ? "0" : String.Format("{0:#,###}", delvAmount);
            string strDc      = dcAmount == 0 ? "0" : String.Format("{0:#,###}", dcAmount);
            string strPoint   = pointAmount == 0 ? "0" : String.Format("{0:#,###}", pointAmount);
            string strVoucher = voucherAmount == 0 ? "0" : String.Format("{0:#,###}", voucherAmount);
            double etc        = dcAmount + couponAmount + eventPointAmount;
            string strEtc     = etc == 0 ? "0" : String.Format("{0:#,###}", etc);

            double total    = cashAmount + creditCardAmount + pointAmount + voucherAmount + etc;
            string strTotal = total == 0 ? "0" : String.Format("{0:#,###}", total);
            double gap      = totalPay - total;
            string strGap   = gap == 0 ? "0" : String.Format("{0:#,###}", gap);

            PrintDocument doc = new PrintDocument();

            doc.PrinterSettings.PrinterName = COM.RawPrinterHelper.printerName;
            doc.PrintPage += new PrintPageEventHandler(doc_PrintPage);

            try
            {
                string str = "";

                str  = "[" + storeCd + "] " + locNm + "\n";
                str += "OPEN: " + openTime + " - " + closeTime + "\n";
                str += "TIME: " + startDate + " - " + endDate + "\n";
                str += "[DATE]: " + DateTime.Now.ToString() + "\n";
                str += "==========================================\n";
                str += "[ITEM SALE INFO]\n";
                str += "  Item Amount : " + strItemAmount.PadLeft(26, ' ') + "\n";
                str += "------------------------------------------\n";
                str += "[ITEM RETURN INFO]\n";
                str += "  Item Amount : " + strItemReturn.PadLeft(26, ' ') + "\n";
                str += "------------------------------------------\n";
                str += "  ITEM TOTAL : " + strItemTotal.PadLeft(27, ' ') + "\n";
                str += "==========================================\n";
                str += "[PAYMENT INFO]\n";
                str += "  Cash : " + strCash.PadLeft(33, ' ') + "\n";
                str += "  Card : " + strCard.PadLeft(33, ' ') + "\n";
                str += "  Point Use : " + strPoint.PadLeft(28, ' ') + "\n";
                str += "  Gift Card : " + strVoucher.PadLeft(28, ' ') + "\n";
                str += "  Etc : " + strEtc.PadLeft(34, ' ') + "\n";
                str += "------------------------------------------\n";
                str += "  Amount of Pay : " + strTotal.PadLeft(24, ' ') + "\n";
                //str += "  Over Pay : " + strGap.PadLeft(29, ' ') + "\n";
                str += "\n";
                COM.RawPrinterHelper.SendStringToPrinter(COM.RawPrinterHelper.printerName, str);
                doc.Print();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Print Pick Order Paper");
            }
        }
Ejemplo n.º 30
0
        private void gridViewReturnDetail_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            int  tmp_return_qty = 0;
            int  tmp_remain_qty = 0;          //Calculation pickup quantity after update
            int  selRow = gridViewReturnDetail.FocusedRowHandle;
            bool bolPickDone = false;
            int  chkOrderQty, chkReturnQty, chkRemainQty, chkCancelQty;

            ret_yn = gridViewReturn.GetRowCellValue(gridViewReturn.FocusedRowHandle, "ret_yn").ToString();

            if (ret_yn == "Y" || e.Column.FieldName != "ret_qty")
            {
                gridViewReturnDetail.CancelUpdateCurrentRow();

                bolCellChanging = false;
                return;
            }

            if (!String.IsNullOrEmpty(e.Value.ToString()) && !e.Value.ToString().StartsWith("-") && int.TryParse(e.Value.ToString(), out tmp_return_qty))
            {
                tmp_return_qty = int.Parse(e.Value.ToString());
                tmp_remain_qty = ord_qty - tmp_return_qty - cancel_qty;

                // Pickup quantity are not change
                if (tmp_return_qty == ret_qty)
                {
                    //XtraMessageBox.Show("픽업 수량은 변경되지 않습니다.", "성공");
                    XtraMessageBox.Show("Số lượng trả hàng không thay đổi.", "Thông báo");
                    bolCellChanging = false;
                    return;
                }
            }
            else
            {
                //XtraMessageBox.Show("픽업 수량은 0과 주문 수량 사이 여야합니다.", "성공");
                XtraMessageBox.Show("Số lượng trả hàng phải lớn hơn 0 và nhỏ hơn số lượng đặt hàng.", "Thông báo");
                //gridViewPickupDetail.SetRowCellValue(selRow, STR_PICK_QTY, pick_qty);
                gridViewReturnDetail.CancelUpdateCurrentRow();
                bolCellChanging = false;
                return;
            }

            // Pickup quantity > order quantity
            if ((tmp_return_qty + cancel_qty) > ord_qty || tmp_remain_qty < 0)
            {
                //if (XtraMessageBox.Show("픽업 수량이 주문 수량보다 큽니다. 그들 모두를 선택?", "확인", MessageBoxButtons.OKCancel) == DialogResult.OK)
                if (XtraMessageBox.Show("Số lượng trả hàng đang lớn hơn số lượng đặt hàng. \nBạn có muốn cập nhật lại thành số lượng đặt hàng không?", "Xác nhận", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    tmp_return_qty = ord_qty;
                    tmp_remain_qty = 0;
                    bolPickDone    = true;
                    //gridViewPickupDetail.SetRowCellValue(selRow, STR_PICK_QTY, ord_qty);
                    //gridViewPickupDetail.SetRowCellValue(selRow, STR_REMAIN_QTY, 0);
                }
                else
                {
                    //XtraMessageBox.Show("픽업 수량은 0과 주문 수량 사이 여야합니다.", "성공");
                    XtraMessageBox.Show("Số lượng trả hàng phải lớn hơn 0 và nhỏ hơn số lượng đặt hàng.", "Thông báo");
                    gridViewReturnDetail.CancelUpdateCurrentRow();
                    bolCellChanging = false;
                    return;
                }
            }
            // Order quantity is equal to pickup quantity: Update status of pickup to done
            else if (ord_qty == (tmp_return_qty + cancel_qty))
            {
                bolPickDone = true;
            }
            // Order quantity is still greater than pickup quantity: Update status of pickup to retry
            else
            {
                bolPickDone = false;
            }

            ret_no = gridViewReturn.GetRowCellValue(gridViewReturn.FocusedRowHandle, "ret_no").ToString();
            ord_no = gridViewReturn.GetRowCellValue(gridViewReturn.FocusedRowHandle, "ord_no").ToString();

            // Update Pickup detail
            JsonRequest   request = new JsonRequest();
            StringBuilder sql     = new StringBuilder();

            ProcAction updateReturnDetail = request.NewAction();

            updateReturnDetail.proc = WebUtil.Values.PROC_SQL;

            sql.Append("UPDATE " + HBConstant.TB_SO_RETURN_DTL);
            sql.Append(" SET ret_qty = #{ret_qty}, remain_qty = #{remain_qty}, up_id = #{up_id}, up_dt = CURRENT_TIMESTAMP");
            sql.Append(" WHERE ret_dtl_id = #{ret_dtl_id} AND ret_id = #{ret_id} AND ret_no = #{ret_no}");

            updateReturnDetail.text = sql.ToString();
            updateReturnDetail.param.Add("ret_qty", tmp_return_qty);
            updateReturnDetail.param.Add("remain_qty", tmp_remain_qty);
            updateReturnDetail.param.Add(HBConstant.C_UP_ID, COM.UserInfo.UserID);
            updateReturnDetail.param.Add("ret_dtl_id", gridViewReturnDetail.GetRowCellValue(selRow, "ret_dtl_id"));
            updateReturnDetail.param.Add("ret_id", gridViewReturnDetail.GetRowCellValue(selRow, "ret_id"));
            updateReturnDetail.param.Add("ret_no", gridViewReturnDetail.GetRowCellValue(selRow, "ret_no"));

            // If current pickup is done, check other pickups
            if (bolPickDone && gridViewReturnDetail.RowCount > 1)
            {
                for (int i = 0; i < gridViewReturnDetail.RowCount; i++)
                {
                    chkOrderQty  = int.Parse(gridViewReturnDetail.GetRowCellValue(i, "ord_qty").ToString());
                    chkReturnQty = int.Parse(gridViewReturnDetail.GetRowCellValue(i, "ret_qty").ToString());
                    chkRemainQty = int.Parse(gridViewReturnDetail.GetRowCellValue(i, "remain_qty").ToString());
                    chkCancelQty = int.Parse(gridViewReturnDetail.GetRowCellValue(i, "cancel_qty").ToString());
                    if (i != selRow && (chkOrderQty != (chkReturnQty + chkCancelQty) || chkRemainQty != 0))
                    {
                        bolPickDone = false;
                        break;
                    }
                }
            }

            // Update type when return all products of Return
            ProcAction updateReturn = request.NewAction();

            updateReturn.proc = WebUtil.Values.PROC_SQL;
            sql.Clear();

            sql.Append("UPDATE " + HBConstant.TB_SO_RETURN);
            sql.Append(" SET ret_tp = #{ret_tp}, up_id = #{up_id}, up_dt = CURRENT_TIMESTAMP");
            sql.Append(" WHERE ret_id = #{ret_id} AND ret_no = #{ret_no}");

            updateReturn.text = sql.ToString();
            if (bolPickDone)
            {
                updateReturn.param.Add("ret_tp", "total");
            }
            else
            {
                updateReturn.param.Add("ret_tp", "part");
            }
            updateReturn.param.Add(HBConstant.C_UP_ID, COM.UserInfo.UserID);
            updateReturn.param.Add("ret_id", gridViewReturnDetail.GetRowCellValue(selRow, "ret_id"));
            updateReturn.param.Add("ret_no", gridViewReturnDetail.GetRowCellValue(selRow, "ret_no"));

            WebClient client = new WebClient();
            DataSet   ds     = client.Execute(request);

            if (client.check)
            {
                // TODO Message
                //XtraMessageBox.Show("픽업 주문이 업데이트되었습니다.", "성공");
                int selReturn = gridViewReturn.FocusedRowHandle;
                if (bolPickDone)
                {
                    gridViewReturn.SetRowCellValue(selReturn, "ret_tp", "total");
                    gridViewReturn.SetRowCellValue(selReturn, "ret_tp_nm", "Total");
                    ord_no = String.Empty;
                    ret_no = String.Empty;
                }
                else
                {
                    gridViewReturn.SetRowCellValue(selReturn, "ret_tp", "part");
                    gridViewReturn.SetRowCellValue(selReturn, "ret_tp_nm", "Part");
                }

                gridViewReturn.RefreshData();
                gridViewReturnDetail.RefreshData();
                SearchReturnDetail(selReturn);
            }
            else
            {
                //XtraMessageBox.Show("픽업 주문 업데이트 실패 : " + client.message, "실패");
                XtraMessageBox.Show("Có lỗi xảy ra: \n" + client.message, "Lỗi");
                gridViewReturnDetail.CancelUpdateCurrentRow();
            }

            bolCellChanging = false;
        }