예제 #1
0
        DataTable Search(string text)
        {
            WebUtil.JsonRequest request = new WebUtil.JsonRequest();

            WebUtil.ProcAction action = request.NewAction();
            StringBuilder      sql    = new StringBuilder();

            int  search_cd;
            bool isNumber = int.TryParse(text, out search_cd);

            action.proc = "sql";

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

            // The first time, we will finding with loc_cd
            // The next time, find with post cod or loc_cd, loc_nm, addr like searching string
            if (bolLocCd && !String.IsNullOrEmpty(text))
            {
                sql.Append(" WHERE loc_cd = #{loc_cd} ");
                action.param.Add("loc_cd", text);
            }
            else if (isNumber)
            {
                sql.Append(" WHERE loc_cd like concat('%', #{search_cd}, '%') ");
                sql.Append(" OR loc_post_cd like concat('%', #{search_cd}, '%') ");
                action.param.Add("search_cd", search_cd);
            }
            else
            {
                sql.Append(" WHERE loc_nm like concat('%', #{loc_nm}, '%') ");
                sql.Append(" OR (loc_addr IS NULL OR loc_addr like concat('%', #{loc_nm}, '%')) ");
                sql.Append(" OR (loc_addr_dtl IS NULL OR loc_addr_dtl like concat('%', #{loc_nm}, '%')) ");
                action.param.Add("loc_nm", text);
            }
            bolLocCd = false;

            sql.Append(" ORDER BY loc_cd ASC ");

            action.text = sql.ToString();


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

            if (client.check && ds != null && ds.Tables.Count > 0)
            {
                return(ds.Tables[0]);
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        public void SearchServer()
        {
            WebUtil.JsonRequest request = new WebUtil.JsonRequest();

            WebUtil.ProcAction action = request.NewAction();
            action.proc = "sql";
            action.text = "select * from tb_sys_version order by file_nm asc";

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

            gridControl1.DataSource = ds.Tables[0];
        }
예제 #3
0
        void Search()
        {
            WebUtil.JsonRequest request = new WebUtil.JsonRequest();

            WebUtil.ProcAction action1 = request.NewAction();
            action1.proc = WebUtil.Values.PROC_SQL;
            action1.text = "select *, '' iud_flag from tb_sys_grid where concat(grid_id, grid_name, dll_name, class_name) like concat('%', #{find}, '%') ";
            action1.param.Add("find", scFind.Text);

            WebUtil.WebClient client = new WebUtil.WebClient();

            DataSet ds = client.Execute(request);

            gridControl1.DataSource = ds.Tables[0];
        }
예제 #4
0
        public int SearchVersion(string fileName)
        {
            WebUtil.JsonRequest request = new WebUtil.JsonRequest();

            WebUtil.ProcAction action = request.NewAction();
            action.proc = "sql";
            action.text = "select * from tb_sys_version where file_nm = #{file_nm}";
            action.param.Add("file_nm", fileName);

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

            if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
            {
                return -1;
            }
            else
            {
                return Convert.ToInt32(ds.Tables[0].Rows[0]["file_ver"].ToString());
            }
        }
예제 #5
0
        DataTable Search(string text)
        {
            WebUtil.JsonRequest request = new WebUtil.JsonRequest();

            WebUtil.ProcAction action = request.NewAction();
            action.proc = "sql";
            action.text = "select * from tb_sys_text where concat(id, ko, en, vi) like concat('%', #{text}, '%')";
            action.param.Add("text", text);

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

            if (client.check && ds != null && ds.Tables.Count > 0)
            {
                return(ds.Tables[0]);
            }
            else
            {
                return(null);
            }
        }
예제 #6
0
        void SearchDetail(int row)
        {
            if (row < 0)
            {
                gridControl2.DataSource = null;
                return;
            }

            WebUtil.JsonRequest request = new WebUtil.JsonRequest();

            WebUtil.ProcAction action1 = request.NewAction();
            action1.proc = WebUtil.Values.PROC_SQL;
            action1.text = "select *, '' col_text from tb_sys_grid_col where grid_id = #{grid_id} order by col_idx asc";
            action1.param.Add("grid_id", gridView1.GetRowCellValue(row, "grid_id"));

            WebUtil.WebClient client = new WebUtil.WebClient();

            DataSet ds = client.Execute(request);

            gridControl2.DataSource = ds.Tables[0];

            for (int i = 0; i < gridView2.RowCount; i++)
            {
                string text_id = (string)gridView2.GetRowCellValue(i, "col_text_id");
                if (text_id != null && text_id != "")
                {
                    Dictionary <string, string> dic = CommonUtil.AccessDB.GetTextDictionary(text_id);

                    if (dic == null || dic.Count == 0)
                    {
                        gridView2.SetRowCellValue(i, "col_text", "{\"ko\":\"\",\"en\":\"\",\"vi\":\"\"}");
                    }
                    else
                    {
                        gridView2.SetRowCellValue(i, "col_text", CommonUtil.Converter.GetNameJson(dic));
                    }
                }
            }
        }
예제 #7
0
        void Search()
        {
            WebUtil.JsonRequest request = new WebUtil.JsonRequest();

            WebUtil.ProcAction action = request.NewAction();
            action.proc = "sql";
            //action.text = "select a.user_id, a.user_nm, a.loc_cd, ifnull(b.loc_nm, '') loc_nm, ifnull(b.loc_addr, '') loc_addr, ifnull(b.tel_no, '') tel_no, b.store_cd, b.pos_no ";
            action.text  = "select a.user_id, a.user_nm, a.loc_cd, ifnull(b.loc_nm, '') loc_nm, ifnull(b.loc_addr, '') loc_addr, ifnull(b.tel_no, '') tel_no, b.store_cd, b.pos_no, ifnull(a.role_id, '') role_id ";
            action.text += "from tb_sys_user a ";
            action.text += "	left join tb_ma_pickup_loc b on a.loc_cd = b.loc_cd ";
            //action.text += "where a.use_yn = 'Y' and a.user_id = #{user_id} and CAST(FROM_BASE64(a.user_pw) AS CHAR CHARACTER SET utf8) = #{user_pw}";
            action.text += "where a.use_yn = 'Y' and a.user_id = #{user_id} and a.user_pw = #{user_pw}";
            //action.text += "where a.use_yn = 'Y' and a.user_id = #{user_id}";
            action.param.Add("user_id", etId.Text);
            action.param.Add("user_pw", COM.AES256.AESEncrypt256(etPw.Text));

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

            if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
            {
                //XtraMessageBox.Show("Login Failed...");
                XtraMessageBox.Show("Đăng nhập thất bại.", "Lỗi");
                etId.Focus();
            }
            else
            {
                DataTable dt = ds.Tables[0];
                COM.UserInfo.UserID   = dt.Rows[0]["user_id"].ToString();
                COM.UserInfo.UserName = dt.Rows[0]["user_nm"].ToString();
                COM.UserInfo.LocCode  = dt.Rows[0]["loc_cd"].ToString();
                COM.UserInfo.LocName  = dt.Rows[0]["loc_nm"].ToString();
                COM.UserInfo.LocAddr  = dt.Rows[0]["loc_addr"].ToString();
                COM.UserInfo.LocTelNo = dt.Rows[0]["tel_no"].ToString();
                COM.UserInfo.StoreCd  = dt.Rows[0]["store_cd"].ToString();
                COM.UserInfo.PosNo    = dt.Rows[0]["pos_no"].ToString();
                //COM.UserInfo.StoreCd = "9999";
                //COM.UserInfo.PosNo = "9000";
                COM.UserInfo.RoleID = dt.Rows[0]["role_id"].ToString();

                if (chkLoginInfoSave.Checked && COM.UserInfo.RoleID == "0")
                {
                    CommonUtil.AccessDB.SetConfig("login_info_save", "Y");
                    CommonUtil.AccessDB.SetConfig("user_id", etId.Text);
                    CommonUtil.AccessDB.SetConfig("user_pw", CommonUtil.Converter.Encrypt(etPw.Text));
                    CommonUtil.AccessDB.SetConfig("if_flag", "Y");
                    CommonUtil.AccessDB.SetConfig("cancel_flag", "Y");
                }
                else
                {
                    CommonUtil.AccessDB.SetConfig("login_info_save", chkLoginInfoSave.Checked? "Y" : "N");
                    CommonUtil.AccessDB.SetConfig("user_id", chkLoginInfoSave.Checked ? etId.Text : "");
                    CommonUtil.AccessDB.SetConfig("user_pw", chkLoginInfoSave.Checked ? CommonUtil.Converter.Encrypt(etPw.Text) : "");
                    CommonUtil.AccessDB.SetConfig("if_flag", "N");
                    CommonUtil.AccessDB.SetConfig("cancel_flag", "N");
                }

                Main mainForm = (Main)this.Parent;
                mainForm.AfterLogin();

                this.Dispose();
            }
        }
예제 #8
0
        private async void gridControl2_DoubleClick(object sender, EventArgs e)
        {
            DXMouseEventArgs ea = e as DXMouseEventArgs;
            GridView view = gridView2;
            GridHitInfo info = view.CalcHitInfo(ea.Location);
            if (info.InRow || info.InRowCell)
            {
                string fileName = gridView2.GetRowCellValue(info.RowHandle, "file_nm").ToString();
                string filePath = gridView2.GetRowCellValue(info.RowHandle, "file_path").ToString();
                var uri = new Uri(System.Configuration.ConfigurationSettings.AppSettings["apiServerVersionUrl"]);

                //CommonUtil.Progress.OpenProgress(this);

                try
                {
                    for (int i = 0; i < sftpUrl.Length; i++)
                    {
                        Sftp oSftp = new Sftp(sftpUrl[i], sftpId[i], sftpPw[i]);
                        oSftp.Connect(Convert.ToInt32(sftpPort[i]));
                        oSftp.Put(filePath, sftpDir[i] + "/" + fileName);
                        oSftp.Close();
                    }

                    int version = SearchVersion(fileName);

                    WebUtil.JsonRequest request = new WebUtil.JsonRequest();

                    WebUtil.ProcAction action = request.NewAction();
                    action.proc = "sql";
                    if (version == -1)
                    {
                        action.text = "insert into tb_sys_version(file_nm, file_ver, in_dt, up_dt) values(#{file_nm}, 1, now(), now())";
                    }
                    else
                    {
                        action.text = "update tb_sys_version set file_ver = #{file_ver}, up_dt = now() where file_nm = #{file_nm}";
                        action.param.Add("file_ver", version + 1);
                    }
                    action.param.Add("file_nm", fileName);

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

                    SearchServer();
                }
                catch (Exception err)
                {
                    throw new Exception(err.ToString());
                }
                finally
                {
                    //CommonUtil.Progress.CloseProgress(this);
                }




                //byte[] data;
                //ByteArrayContent bytes;

                //MultipartFormDataContent multiForm = new MultipartFormDataContent();

                //try
                //{

                //    FileInfo fileinfo = new FileInfo(filePath);

                //    using (var client = new HttpClient())
                //    {
                //        using (var br = new BinaryReader(fileinfo.OpenRead()))
                //        {
                //            data = br.ReadBytes((int)fileinfo.OpenRead().Length);
                //        }

                //        bytes = new ByteArrayContent(data);
                //        multiForm.Add(bytes, "file_nm", fileName);

                //        var res = await client.PostAsync(uri, multiForm);
                //    }
                    

                //    SearchServer();
                //}
                //catch (Exception err)
                //{
                //    throw new Exception(err.ToString());
                //}
                //finally
                //{
                //    CommonUtil.Progress.CloseProgress(this);
                //}
            }  
        }
예제 #9
0
        void Save()
        {
            if (gridView1.RowCount == 0)
            {
                return;
            }

            if (etGridId.Text == "")
            {
                //XtraMessageBox.Show("그리드ID는 필수입력입니다.", "경고");
                XtraMessageBox.Show("Id của bảng đang để trống.", "Thông báo");
                return;
            }

            WebUtil.JsonRequest request = new WebUtil.JsonRequest();

            string iudFlag = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "iud_flag").ToString();

            if (iudFlag == "I")
            {
                WebUtil.ProcAction gridAction = request.NewAction();
                gridAction.proc  = WebUtil.Values.PROC_SQL;
                gridAction.text  = "insert into tb_sys_grid(grid_id, dll_name, class_name, grid_name, grid_desc, in_id, up_id) ";
                gridAction.text += "values(#{grid_id}, #{dll_name}, #{class_name}, #{grid_name}, #{grid_desc}, #{user_id}, #{user_id})";
                gridAction.param.Add("grid_id", etGridId.Text);
                gridAction.param.Add("dll_name", etDllName.Text);
                gridAction.param.Add("class_name", etClassName.Text);
                gridAction.param.Add("grid_name", etGridName.Text);
                gridAction.param.Add("grid_desc", etGridDesc.Text);
                gridAction.param.Add("user_id", COM.UserInfo.UserID);
            }
            else
            {
                WebUtil.ProcAction gridAction = request.NewAction();
                gridAction.proc  = WebUtil.Values.PROC_SQL;
                gridAction.text  = "update tb_sys_grid set dll_name = #{dll_name}, class_name = #{class_name}, grid_name = #{grid_name}, ";
                gridAction.text += "grid_desc = #{grid_desc}, up_id = #{user_id} where grid_id = #{grid_id}";
                gridAction.param.Add("grid_id", etGridId.Text);
                gridAction.param.Add("dll_name", etDllName.Text);
                gridAction.param.Add("class_name", etClassName.Text);
                gridAction.param.Add("grid_name", etGridName.Text);
                gridAction.param.Add("grid_desc", etGridDesc.Text);
                gridAction.param.Add("user_id", COM.UserInfo.UserID);
            }

            WebUtil.ProcAction deleteAction = request.NewAction();
            deleteAction.proc = WebUtil.Values.PROC_SQL;
            deleteAction.text = "delete from tb_sys_grid_col where grid_id = #{grid_id} ";
            deleteAction.param.Add("grid_id", etGridId.Text);

            for (int i = 0; i < gridView2.RowCount; i++)
            {
                WebUtil.ProcAction colAction = request.NewAction();
                colAction.proc  = WebUtil.Values.PROC_SQL;
                colAction.text  = "insert into tb_sys_grid_col(grid_id, in_id, up_id, mandatory_yn, visible_yn, ";
                colAction.text += "readonly_yn, allow_focus_yn, sort_yn, filter_yn, col_idx, col_text_id, field_name, col_width, col_align, ";
                colAction.text += "decimal_places, sub_total, sum_type, value_checked, value_unchecked, header_checkbox, mask, default_row, ";
                colAction.text += "default_row_value, default_row_name, action_proc, action_text, action_param, col_type, dll_name, class_name) ";
                colAction.text += "values(#{grid_id}, #{user_id}, #{user_id}, #{mandatory_yn}, #{visible_yn}, #{readonly_yn}, ";
                colAction.text += "#{allow_focus_yn}, #{sort_yn}, #{filter_yn}, #{col_idx}, #{col_text_id}, #{field_name}, #{col_width}, ";
                colAction.text += "#{col_align}, #{decimal_places}, #{sub_total}, #{sum_type}, #{value_checked}, #{value_unchecked}, ";
                colAction.text += "#{header_checkbox}, #{mask}, #{default_row}, #{default_row_value}, #{default_row_name}, #{action_proc}, ";
                colAction.text += "#{action_text}, #{action_param}, #{col_type}, #{dll_name}, #{class_name})";
                colAction.param.Add("grid_id", etGridId.Text);
                colAction.param.Add("user_id", COM.UserInfo.UserID);
                colAction.param.Add("mandatory_yn", gridView2.GetRowCellValue(i, "mandatory_yn"));
                colAction.param.Add("visible_yn", gridView2.GetRowCellValue(i, "visible_yn"));
                colAction.param.Add("readonly_yn", gridView2.GetRowCellValue(i, "readonly_yn"));
                colAction.param.Add("allow_focus_yn", gridView2.GetRowCellValue(i, "allow_focus_yn"));
                colAction.param.Add("sort_yn", gridView2.GetRowCellValue(i, "sort_yn"));
                colAction.param.Add("filter_yn", gridView2.GetRowCellValue(i, "filter_yn"));
                colAction.param.Add("col_idx", gridView2.GetRowCellValue(i, "col_idx"));
                colAction.param.Add("col_text_id", gridView2.GetRowCellValue(i, "col_text_id"));
                colAction.param.Add("field_name", gridView2.GetRowCellValue(i, "field_name"));
                colAction.param.Add("col_width", gridView2.GetRowCellValue(i, "col_width"));
                colAction.param.Add("col_align", gridView2.GetRowCellValue(i, "col_align"));
                colAction.param.Add("decimal_places", gridView2.GetRowCellValue(i, "decimal_places"));
                colAction.param.Add("sub_total", gridView2.GetRowCellValue(i, "sub_total"));
                colAction.param.Add("sum_type", gridView2.GetRowCellValue(i, "sum_type"));
                colAction.param.Add("value_checked", gridView2.GetRowCellValue(i, "value_checked"));
                colAction.param.Add("value_unchecked", gridView2.GetRowCellValue(i, "value_unchecked"));
                colAction.param.Add("header_checkbox", gridView2.GetRowCellValue(i, "header_checkbox"));
                colAction.param.Add("mask", gridView2.GetRowCellValue(i, "mask"));
                colAction.param.Add("default_row", gridView2.GetRowCellValue(i, "default_row"));
                colAction.param.Add("default_row_value", gridView2.GetRowCellValue(i, "default_row_value"));
                colAction.param.Add("default_row_name", gridView2.GetRowCellValue(i, "default_row_name"));
                colAction.param.Add("action_proc", gridView2.GetRowCellValue(i, "action_proc"));
                colAction.param.Add("action_text", gridView2.GetRowCellValue(i, "action_text"));
                colAction.param.Add("action_param", gridView2.GetRowCellValue(i, "action_param"));
                colAction.param.Add("col_type", gridView2.GetRowCellValue(i, "col_type"));
                colAction.param.Add("dll_name", gridView2.GetRowCellValue(i, "dll_name"));
                colAction.param.Add("class_name", gridView2.GetRowCellValue(i, "class_name"));
            }

            WebUtil.WebClient client = new WebUtil.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
            {
                Console.WriteLine(client.message);
                //XtraMessageBox.Show("저장 실패: " + client.message, "실패");
                XtraMessageBox.Show("Có lỗi xảy ra: \n" + client.message, "Lỗi");
            }
        }