Esempio n. 1
0
        void HuyTaiKhoan()
        {
            try
            {
                string  sql_Exect     = string.Format("Exec sp_HuyUser @ID ='{0}' ", ID);
                string  sLink         = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect;
                var     json          = API.API_GET(sLink);
                dynamic jsondata      = JObject.Parse(json);
                var     jsondataChild = jsondata.GetValue("Data");
                var     Result        = jsondataChild.First.GetValue("Result").Value;
                var     Message       = jsondataChild.First.GetValue("Message").Value;

                if (Result == 1)//Login thành công
                {
                    XtraMessageBox.Show(Message, "Thông Báo");
                }
                else
                {
                    XtraMessageBox.Show("Hủy Tài Khoản Không Thành Công", "Thông Báo");
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Frm_NhomQuyen", "HuyTaiKhoan()", ex.ToString()));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Load Thông tin Nhóm Sản Phẩm
        /// </summary>
        private void LoadInfoProductGroup()
        {
            try
            {
                string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByStore?sql_Exec=" + "sp_ProductGroup_Getdata";
                var    json  = API.API_GET(sLink);

                var       jsondata = JObject.Parse(json).GetValue("Data");
                DataTable dt       = (DataTable)JsonConvert.DeserializeObject(jsondata.ToString(), (typeof(DataTable)));
                listHeader = JsonConvert.DeserializeObject <List <ProductGroupHeader> >(jsondata.ToString());

                dgc_Main.DataSource = listHeader;
                if (listHeader == null || listHeader.Count == 0)
                {
                    listdetails           = new List <ProductGroupDetails>();
                    dgcDetails.DataSource = listdetails;
                    dgvDetails.RefreshData();
                }
                dgv_Main.BestFitColumns(true);
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_ProductGroup", "LoadInfoProductGroup()", ex.ToString()));
            }
        }
Esempio n. 3
0
        private void btnDeleteAll_Click(object sender, EventArgs e)
        {
            if (DialogResult.No == XtraMessageBox.Show("Bạn có muốn xóa toàn bộ sản phẩm không? Nhấn Yes để thực hiện!", "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                return;
            }

            try
            {
                btnXoaAll.Enabled = false;
                string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_DeleteAllProduct";

                var     json          = API.API_GET(sLink);
                dynamic jsondata      = JObject.Parse(json);
                var     jsondataChild = jsondata.GetValue("Data");
                var     Result        = jsondataChild.First.GetValue("Result").Value;
                var     Message       = jsondataChild.First.GetValue("Message").Value;

                if (Result == 1)//Login thành công
                {
                    XtraMessageBox.Show(Message, "Thông Báo");
                    LoadInfoProduct();
                }
                else
                {
                    XtraMessageBox.Show("Xóa Dữ Liệu KHông Thành Công", "Thông Báo");
                }
                btnXoaAll.Enabled = true;
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Product", "btnDeleteAll_Click", ex.ToString()));
            }
        }
Esempio n. 4
0
        private void XoaBaoGia()
        {
            DialogResult result = XtraMessageBox.Show("Bạn Có muốn Xóa Báo Giá này không?", "Thông Báo", MessageBoxButtons.YesNo);

            if (result == DialogResult.No)
            {
                return;
            }
            try
            {
                // Create an empty list.
                int focus = dgv_Main.FocusedRowHandle;
                if (focus >= 0)
                {
                    InfoCustomer dr = (InfoCustomer)dgv_Main.GetFocusedRow();
                    if (dr != null)
                    {
                        listob.Remove(dr);
                        //  dgc_Main.DataSource = listob;
                        dgv_Main.RefreshData();
                        // Xóa data
                        string sql_Exect = string.Format("Exec sp_Quote_Delete " +
                                                         "@ID={0}", dr.ID); //11
                        string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect;
                        var    json  = API.API_GET(sLink);
                    }
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_TimKiemBaoGia", "XoaBaoGia()", ex.ToString()));
            }
        }
Esempio n. 5
0
        private void XoaDuLieu(string MaSP)
        {
            try
            {
                string sql_Exect = string.Format("Exec sp_Product_Delete @ID ='{0}', @UserName='******'", MaSP, Form_Main.user.Username);

                string  sLink         = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect;
                var     json          = API.API_GET(sLink);
                dynamic jsondata      = JObject.Parse(json);
                var     jsondataChild = jsondata.GetValue("Data");
                var     Result        = jsondataChild.First.GetValue("Result").Value;
                var     Message       = jsondataChild.First.GetValue("Message").Value;

                if (Result == 1)                //Login thành công
                {
                    XtraMessageBox.Show(Message, "Thông Báo");
                    LoadInfoProduct();
                }
                else
                {
                    XtraMessageBox.Show(Message, "Thông Báo");
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Product", "XoaDuLieu()", ex.ToString()));
            }
        }
Esempio n. 6
0
        private void LoadDSPhanQuyenTheoTenNhom(string tennhom)
        {
            try
            {
                string sql_Exect = string.Format("Exec sp_GetDSChiTietPQ @TenNhom='{0}'", tennhom); //11

                string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect;
                var    json  = API.API_GET(sLink);

                var jsondata = JObject.Parse(json).GetValue("Data");

                DataTable dt = (DataTable)JsonConvert.DeserializeObject(jsondata.ToString(), (typeof(DataTable)));
                if (dt != null && dt.Rows.Count > 0)
                {
                    string KEYLIST = dt.Rows[0]["IDChucNang"].ToString();
                    if (KEYLIST == null || KEYLIST == ",,")
                    {
                        for (int i = 0; i < grv_NhomQuyen.RowCount; i++)
                        {
                            grv_NhomQuyen.SetRowCellValue(i, "Chon", "False");
                        }
                    }
                    else
                    {
                        grv_NhomQuyen.ExpandAllGroups();
                        for (int i = 0; i < grv_NhomQuyen.RowCount; i++)
                        {
                            DataRow dr = grv_NhomQuyen.GetDataRow(i);
                            if (dr != null)
                            {
                                string ID = dr["ID"].ToString();
                                if (ID != null && KEYLIST.Contains(ID))
                                {
                                    grv_NhomQuyen.SetRowCellValue(i, "Chon", "True");
                                }
                                else
                                {
                                    grv_NhomQuyen.SetRowCellValue(i, "Chon", "False");
                                }
                            }
                        }
                    }
                }
                grv_NhomQuyen.RefreshData();
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Frm_NhomQuyen", "LoadDSPhanQuyenTheoTenNhom()", ex.ToString()));
            }
        }
Esempio n. 7
0
        private void LoadDSNhom()
        {
            try
            {
                string sql_Exect = "Exec sp_GetNhomQuyen"; //11

                string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect;
                var    json  = API.API_GET(sLink);

                var jsondata = JObject.Parse(json).GetValue("Data");

                DataTable dt = (DataTable)JsonConvert.DeserializeObject(jsondata.ToString(), (typeof(DataTable)));

                if (dt != null && dt.Rows.Count > 0)
                {
                    #region xử lý nhóm quyền
                    string ds = dt.Rows[0]["danhsach"].ToString();
                    if (ds != "")
                    {
                        string[] str = ds.Split(';');
                        dsnhomquyen.Clear();
                        dsnhomquyen.AddRange(str);
                        cbb_ThongTinNhom.MaskBox.AutoCompleteCustomSource = dsnhomquyen;
                        cbb_ThongTinNhom.MaskBox.AutoCompleteSource       = AutoCompleteSource.CustomSource;
                        cbb_ThongTinNhom.MaskBox.AutoCompleteMode         = AutoCompleteMode.SuggestAppend;
                    }
                    #endregion xử lý nhóm quyền
                }
                else
                {
                    cbb_ThongTinNhom.MaskBox.AutoCompleteCustomSource = new AutoCompleteStringCollection();
                }

                sql_Exect = "Exec sp_GetNhomQuyen_header"; //11

                sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect;
                json  = API.API_GET(sLink);

                jsondata = JObject.Parse(json).GetValue("Data");

                dt = (DataTable)JsonConvert.DeserializeObject(jsondata.ToString(), (typeof(DataTable)));
                cbbSearchNhom.Properties.DataSource = dt;
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Frm_NhomQuyen", "LoadDSNhom()", ex.ToString()));
            }
        }
Esempio n. 8
0
 private void Logoff()
 {
     try
     {
         if (!string.IsNullOrEmpty(user.Username))
         {
             string sql_Exect = string.Format("Exec sp_extension_Logoff @UserName='******'", user.Username);                     //11
             string sLink     = URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect;
             var    json      = API.API_GET(sLink);
         }
     }
     catch (Exception ex)
     {
         API.API_ERRORLOG(new ERRORLOG(IPAddress, "Form_Main", "Logoff()", ex.ToString()));
     }
 }
Esempio n. 9
0
        /// <summary>
        /// Load Thông Tin Sản Phẩm
        /// </summary>
        private void LoadInfoProduct()
        {
            try
            {
                string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByStore?sql_Exec=" + "sp_Get_Product_Select";
                var    json  = API.API_GET(sLink);

                var jsondata = JObject.Parse(json).GetValue("Data");
                var ds       = JsonConvert.DeserializeObject <List <ProductSelect> >(jsondata.ToString());
                searchSanPham.DataSource = ds;
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_ProductGroup", "LoadInfoProduct()", ex.ToString()));
            }
        }
Esempio n. 10
0
        private void LoadInfoProduct()
        {
            try
            {
                string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByStore?sql_Exec=" + "sp_Get_Product";
                var    json  = API.API_GET(sLink);

                var       jsondata = JObject.Parse(json).GetValue("Data");
                DataTable dt       = (DataTable)JsonConvert.DeserializeObject(jsondata.ToString(), (typeof(DataTable)));
                dgc_Product.DataSource = dt;
                dgv_Product.BestFitColumns(true);
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Product", "LoadInfoProduct()", ex.ToString()));
            }
        }
Esempio n. 11
0
        /// <summary>
        /// lấy danh sách chi tiết nhóm sản phẩm
        /// </summary>
        private void LoadInfoProductDetails(string ListID)
        {
            try
            {
                string sqlQuery = string.Format("exec sp_ProductGroup_GetdataDetails @ID='{0}' ", ListID);
                string sLink    = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sqlQuery;
                var    json     = API.API_GET(sLink);

                var jsondata = JObject.Parse(json).GetValue("Data");
                listdetails           = JsonConvert.DeserializeObject <List <ProductGroupDetails> >(jsondata.ToString());
                dgcDetails.DataSource = listdetails;
                dgvDetails.BestFitColumns(true);
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_ProductGroup", "LoadInfoProductDetails()", ex.ToString()));
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Lưu Thông Tin Nhóm Sản Phẩm
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveProductGroup()
        {
            try
            {
                string TenNhom   = txtTenNhom.Text;
                string DSSanPham = "";

                if (listdetails == null || listdetails.Count == 0)
                {
                    XtraMessageBox.Show("Nhóm chưa có sản phẩm nào!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                foreach (ProductGroupDetails item in listdetails)
                {
                    if (!string.IsNullOrEmpty(item.ID))
                    {
                        int sl = int.Parse(item.SoLuong.ToString());
                        for (int j = 0; j < sl; j++)
                        {
                            DSSanPham = DSSanPham + item.ID + ",";
                        }
                    }
                }

                string  sql_exec      = string.Format("exec sp_ProductGroup_Update @ID='{0}',@ListProduct='{1}',@UserName=N'{2}',@ProductGroupName=N'{3}' ", IDGroup, DSSanPham, Form_Main.user.Username, TenNhom);
                string  sLink         = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_exec;
                var     json          = API.API_GET(sLink);
                dynamic jsondata      = JObject.Parse(json);
                var     jsondataChild = jsondata.GetValue("Data");
                var     Result        = jsondataChild.First.GetValue("Result").Value;
                var     Message       = jsondataChild.First.GetValue("Message").Value;

                if (Result == 1)
                {
                    LoadInfoProductGroup();
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_ProductGroup", "SaveProductGroup()", ex.ToString()));
            }
        }
Esempio n. 13
0
        private void HuyNhom()
        {
            try
            {
                if (DialogResult.Yes == XtraMessageBox.Show("Bạn có muốn bỏ nhóm quyền này không?", "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    string sql_Exect = string.Format("Exec sp_NhomQuyen_Update @TenNhom='{0}'", cbb_ThongTinNhom.Text);                     //11

                    string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect;
                    var    json  = API.API_GET(sLink);

                    var jsondata = JObject.Parse(json).GetValue("Data");
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Frm_NhomQuyen", "HuyNhom()", ex.ToString()));
            }
        }
Esempio n. 14
0
        private void ThemNhomQuyen()
        {
            try
            {
                string DSNhomquyen = "";
                for (int i = 0; i < grv_NhomQuyen.RowCount; i++)
                {
                    DataRow dr = grv_NhomQuyen.GetDataRow(i);
                    if (dr != null)
                    {
                        string item = dr["ID"].ToString();
                        string chon = dr["Chon"].ToString();
                        if (item != null && item != "" && chon != null && chon == "True")
                        {
                            DSNhomquyen = DSNhomquyen == "" ? item : DSNhomquyen + "," + item;
                        }
                    }
                }
                string sql_Exect = string.Format("Exec sp_CapNhatNhomQuyen @TenNhom='{0}',@CreateBy='{1}',@DSQuyen='{2}'", cbb_ThongTinNhom.Text, Form_Main.user.Username, DSNhomquyen); //11

                string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect;
                var    json  = API.API_GET(sLink);

                var jsondata = JObject.Parse(json).GetValue("Data");

                DataTable dt = (DataTable)JsonConvert.DeserializeObject(jsondata.ToString(), (typeof(DataTable)));
                if (dt != null && dt.Rows.Count > 0)
                {
                    string Message = dt.Rows[0]["Message"].ToString();
                    string Result  = dt.Rows[0]["Result"].ToString();
                    XtraMessageBox.Show(Message, "Thông Báo", MessageBoxButtons.OK);
                    if (Result == "1")
                    {
                        LoadDSNhom();
                    }
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Frm_NhomQuyen", "ThemNhomQuyen()", ex.ToString()));
            }
        }
Esempio n. 15
0
 void DeleteCustomer()
 {
     try
     {
         if (DialogResult.Yes == XtraMessageBox.Show("Bạn có muốn xóa khách hàng này không?", "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
         {
             string del = "";
             for (int i = 0; i < dgv_Main.SelectedRowsCount; i++)
             {
                 DataRow dataRow = (DataRow)dgv_Main.GetDataRow(i);
                 if (dataRow != null)
                 {
                     del = (del == "" ? "" : (del + ";")) + dataRow["ID"].ToString();
                 }
             }
             if (del != "")
             {
                 string  sql_Exect     = string.Format("Exec sp_Customer_Delete @ID ='{0}' ", del);
                 string  sLink         = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect;
                 var     json          = API.API_GET(sLink);
                 dynamic jsondata      = JObject.Parse(json);
                 var     jsondataChild = jsondata.GetValue("Data");
                 var     Result        = jsondataChild.First.GetValue("Result").Value;
                 var     Message       = jsondataChild.First.GetValue("Message").Value;
                 if (Result == 1)//Login thành công
                 {
                     XtraMessageBox.Show(Message, "Thông Báo");
                     sp_Get_Customer();
                     ClearForm();
                 }
                 else
                 {
                     XtraMessageBox.Show("Hủy Khách Hàng Không Thành Công", "Thông Báo");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Customer", "DeleteCustomer()", ex.ToString()));
     }
 }
Esempio n. 16
0
        private void LoadThongTinNhomQuyen()
        {
            try
            {
                string sql_Exect = "Exec sp_GetDanhSachChucNang"; //11

                string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect;
                var    json  = API.API_GET(sLink);

                var jsondata = JObject.Parse(json).GetValue("Data");

                DataTable dt = (DataTable)JsonConvert.DeserializeObject(jsondata.ToString(), (typeof(DataTable)));
                grc_NhomQuyen.DataSource = dt;
                grv_NhomQuyen.BestFitColumns(true);
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Frm_NhomQuyen", "LoadThongTinNhomQuyen()", ex.ToString()));
            }
        }
Esempio n. 17
0
        private void LoadDSBaoGia()
        {
            try
            {
                string sql_Exect = string.Format("Exec sp_getData_Quote_header");                 //11

                string    sLink         = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect;
                var       json          = API.API_GET(sLink);
                dynamic   jsondata      = JObject.Parse(json);
                var       jsondataChild = jsondata.GetValue("Data");
                DataTable dt            = (DataTable)JsonConvert.DeserializeObject(jsondataChild.ToString(), (typeof(DataTable)));

                slk_BaoGia.Properties.DataSource = dt;
                slk_BaoGia.Properties.View.ExpandAllGroups();
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_TimKiemBaoGia", "LoadDSBaoGia()", ex.ToString()));
            }
        }
Esempio n. 18
0
        private void LoadForm()
        {
            string sql_Exect = "Exec sp_Account_GetData"; //11

            string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect;
            var    json  = API.API_GET(sLink);

            var       jsondata = JObject.Parse(json).GetValue("Data");
            DataTable dt       = (DataTable)JsonConvert.DeserializeObject(jsondata.ToString(), (typeof(DataTable)));

            dgc_Main.DataSource = dt;
            dgv_Main.BestFitColumns(true);

            sql_Exect = "Exec sp_GetNhomQuyen_header"; //11

            sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect;
            json  = API.API_GET(sLink);

            jsondata = JObject.Parse(json).GetValue("Data");

            dt = (DataTable)JsonConvert.DeserializeObject(jsondata.ToString(), (typeof(DataTable)));
            cbbNhomQuyen.Properties.DataSource = dt;
        }
Esempio n. 19
0
        /// <summary>
        /// Xóa Line
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeleteGroup()
        {
            try
            {
                if (IDGroup == "0")
                {
                    XtraMessageBox.Show("Hãy chọn nhóm sản phẩm mà bạn muốn xóa", "Thông Báo", MessageBoxButtons.OK);
                    return;
                }
                DialogResult result = XtraMessageBox.Show("Bạn có muốn xóa nhóm này không?", "Thông Báo", MessageBoxButtons.YesNo);
                if (result == DialogResult.No)
                {
                    return;
                }

                string  sql_exec      = string.Format("exec sp_ProductGroup_Delete @ID='{0}',@UserName='******'", IDGroup, Form_Main.user.Username);
                string  sLink         = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_exec;
                var     json          = API.API_GET(sLink);
                dynamic jsondata      = JObject.Parse(json);
                var     jsondataChild = jsondata.GetValue("Data");
                var     Result        = jsondataChild.First.GetValue("Result").Value;
                var     Message       = jsondataChild.First.GetValue("Message").Value;
                if (Result == 1)
                {
                    LoadInfoProductGroup();
                }
                else
                {
                    XtraMessageBox.Show(Message, "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Login", "DeleteGroup()", ex.ToString()));
            }
        }
Esempio n. 20
0
 private void LoadBaoGiaAll(string ID)
 {
     try
     {
         string sql_Exect = string.Format("Exec sp_GetQuote_Detail " +
                                          "@ID={0}", ID); //11
         string    sLink         = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect;
         var       json          = API.API_GET(sLink);
         dynamic   jsondata      = JObject.Parse(json);
         var       jsondataChild = jsondata.GetValue("Data");
         DataTable dt            = (DataTable)JsonConvert.DeserializeObject(jsondataChild.ToString(), (typeof(DataTable)));
         listob = new List <InfoCustomer>();
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             InfoCustomer ob = new InfoCustomer();
             ob.ID               = dt.Rows[i]["ID"].ToString();
             ob.SoBaoGia         = dt.Rows[i]["SoBaoGia"].ToString();
             ob.ToKhachHang      = dt.Rows[i]["ToKhachHang"].ToString();
             ob.NguoiNhan        = dt.Rows[i]["NguoiNhan"].ToString();
             ob.Mobile_NguoiNhan = dt.Rows[i]["Mobile_NguoiNhan"].ToString();
             ob.Tel_NguoiNhan    = dt.Rows[i]["Tel_NguoiNhan"].ToString();
             ob.Email_NguoiNhan  = dt.Rows[i]["Email_NguoiNhan"].ToString();
             ob.VAT              = int.Parse(dt.Rows[i]["VAT"].ToString());
             ob.NgayBaoGia       = dt.Rows[i]["NgayBaoGia"].ToString();
             ob.CreateBy         = dt.Rows[i]["CreateBy"].ToString();
             ob.CreateDate       = dt.Rows[i]["CreateDate"].ToString();
             ob.UpdateBy         = dt.Rows[i]["UpdateBy"].ToString();
             ob.UpdateDate       = dt.Rows[i]["UpdateDate"].ToString();
             ob.TongTien         = decimal.Parse(dt.Rows[i]["TongTien"].ToString());
             ob.TongTienAfterVat = decimal.Parse(dt.Rows[i]["TongTienSauThue"].ToString());
             ob.DiaChiKhachHang  = dt.Rows[i]["DiaChi"].ToString();
             ob.DieuKhoan        = dt.Rows[i]["DieuKhoan"].ToString();
             ob.ID_Enquiry       = dt.Rows[i]["ID_Enquiry"].ToString();
             ob.EnquiryName      = dt.Rows[i]["EnquiryName"].ToString();
             ob.IDCardCode       = dt.Rows[i]["IDCardCode"].ToString();
             ob.IDCompany        = dt.Rows[i]["IDCompany"].ToString();
             string xml = dt.Rows[i]["XML"].ToString();
             if (xml != "")
             {
                 XDocument dox = XDocument.Parse(dt.Rows[i]["XML"].ToString());
                 List <InfoReportDetails> lstSP = dox.Descendants("Quote").Select(d =>
                                                                                  new InfoReportDetails
                 {
                     ID          = d.Element("ID").Value,
                     MaSP        = d.Element("MaSP").Value,
                     TenHang     = d.Element("TenHang").Value,
                     MoTaHangHoa = d.Element("MoTa").Value,
                     DonGia      = decimal.Parse(d.Element("DonGia").Value),
                     SoLuong     = int.Parse(d.Element("Quantity").Value),
                     ChietKhau   = decimal.Parse(d.Element("ChietKhau").Value),
                     Profit      = decimal.Parse(d.Element("Profit").Value),
                     CostPrice   = decimal.Parse(d.Element("CostPrice").Value)
                 }).ToList();
                 ob.DSSanPham = lstSP;
             }
             listob.Add(ob);
         }
         dgc_Main.DataSource    = listob;
         dgv_detail.ViewCaption = "Thông Tin Chi Tiết";
         dgv_Main.BestFitColumns(true);
         dgv_detail.BestFitColumns(true);
     }
     catch (Exception ex)
     {
         API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_TimKiemBaoGia", "LoadBaoGiaAll", ex.ToString()));
     }
 }
Esempio n. 21
0
        private void LoadThongTinDefault()
        {
            try
            {
                string sql_Exect = "Exec sp_GetInfoMaster @Key='Info,ImageLeft,ImageRight'"; //11

                string sLink = URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect;
                var    json  = API.API_GET(sLink);

                var       jsondata = JObject.Parse(json).GetValue("Data");
                DataTable dt       = (DataTable)JsonConvert.DeserializeObject(jsondata.ToString(), (typeof(DataTable)));
                string    base64   = dt.Rows[0][0].ToString();

                json = System.Text.Encoding.UTF8.GetString(System.Convert.FromBase64String(base64));
                JObject a = JObject.Parse(json);
                info           = new InfoIPC();
                info.TenCongTy = a.GetValue("TenCongTy").ToString();
                info.NguoiGui  = a.GetValue("NguoiGui").ToString();
                info.Mobile    = a.GetValue("Mobile").ToString();
                info.Email     = a.GetValue("Email").ToString();
                info.DiaChi    = a.GetValue("DiaChi").ToString();


                string FileFolder = AppDomain.CurrentDomain.BaseDirectory + "/AppData/Image";
                if (!Directory.Exists(FileFolder))
                {
                    Directory.CreateDirectory(FileFolder);
                }
                Image  img;
                string image = dt.Rows[1][0].ToString();
                if (image != "")
                {
                    FileFolder = FileFolder + "/" + "ImageLeft.jpg";
                    if (File.Exists(FileFolder))
                    {
                        File.Delete(FileFolder);
                    }
                    try
                    {
                        img = byteArrayToImage(Convert.FromBase64String(image));
                        img.Save(FileFolder);
                    }
                    catch (Exception ex)
                    {
                        API.API_ERRORLOG(new ERRORLOG(IPAddress, "Form_Main", "LoadThongTinDefault() - Save ImageLeft.jpg", ex.ToString()));
                    }
                }
                image = dt.Rows[2][0].ToString();
                if (image != "")
                {
                    FileFolder = AppDomain.CurrentDomain.BaseDirectory + "/AppData/Image";
                    FileFolder = FileFolder + "/" + "ImageRight.jpg";
                    if (!File.Exists(FileFolder))
                    {
                        File.Delete(FileFolder);
                    }
                    try
                    {
                        img = byteArrayToImage(Convert.FromBase64String(image));
                        img.Save(FileFolder);
                    }
                    catch (Exception ex)
                    {
                        API.API_ERRORLOG(new ERRORLOG(IPAddress, "Form_Main", "LoadThongTinDefault() - Save ImageRight.jpg", ex.ToString()));
                    }
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(IPAddress, "Form_Main", "LoadThongTinDefault()", ex.ToString()));
            }
        }
Esempio n. 22
0
        private void LoadThongTinDefaultBeforSave()
        {
            try
            {
                string sql_Exect = "Exec sp_GetInfoMaster @Key='Info,ImageLeft,ImageRight'"; //11

                string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect;
                var    json  = API.API_GET(sLink);

                var       jsondata = JObject.Parse(json).GetValue("Data");
                DataTable dt       = (DataTable)JsonConvert.DeserializeObject(jsondata.ToString(), (typeof(DataTable)));
                string    base64   = dt.Rows[0][0].ToString();

                json = System.Text.Encoding.UTF8.GetString(System.Convert.FromBase64String(base64));
                JObject a = JObject.Parse(json);
                Form_Main.info.TenCongTy = a.GetValue("TenCongTy").ToString();
                Form_Main.info.NguoiGui  = a.GetValue("NguoiGui").ToString();
                Form_Main.info.Mobile    = a.GetValue("Mobile").ToString();
                Form_Main.info.Email     = a.GetValue("Email").ToString();
                Form_Main.info.DiaChi    = a.GetValue("DiaChi").ToString();
                txtTenCty.Text           = Form_Main.info.TenCongTy;
                txtNguoiGui.Text         = Form_Main.info.NguoiGui;
                txtMobile.Text           = Form_Main.info.Mobile;
                txtEmail.Text            = Form_Main.info.Email;
                txtDiaChi.Text           = Form_Main.info.DiaChi;

                string FileFolder = AppDomain.CurrentDomain.BaseDirectory.Replace("\\", "/") + "AppData/Image";
                if (!Directory.Exists(FileFolder))
                {
                    Directory.CreateDirectory(FileFolder);
                }
                if (ptbHinhTrai.Image != null)
                {
                    FileFolder = FileFolder + "/" + "ImageLeft.jpg";
                    if (File.Exists(FileFolder))
                    {
                        if (flag_Image1)
                        {
                            File.Delete(FileFolder);
                            try
                            {
                                ptbHinhTrai.Image.Save(FileFolder, ImageFormat.Jpeg);
                            }
                            catch (Exception ex)
                            {
                                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_MasterData", "ImageLeft()", ex.ToString()));
                            }
                        }
                    }
                }
                if (ptbHinhPhai.Image != null)
                {
                    FileFolder = AppDomain.CurrentDomain.BaseDirectory.Replace("\\", "/") + "AppData/Image";
                    FileFolder = FileFolder + "/" + "ImageRight.jpg";
                    if (File.Exists(FileFolder))
                    {
                        if (flag_Image2)
                        {
                            File.Delete(FileFolder);
                            try
                            {
                                ptbHinhPhai.Image.Save(FileFolder, ImageFormat.Jpeg);
                            }
                            catch (Exception ex)
                            {
                                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_MasterData", "ImageRight()", ex.ToString()));
                            }
                        }
                        else
                        {
                            return;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_MasterData", "LoadThongTinDefaultBeforSave()", ex.ToString()));
            }
        }
Esempio n. 23
0
        private void ExportData()
        {
            try
            {
                btnExport.Enabled = false;
                string             pathFileSave = "";
                XtraSaveFileDialog fileSave     = new XtraSaveFileDialog();
                fileSave.Filter = "Excel files (.xlsx)|*.xlsx";
                fileSave.AutoUpdateFilterDescription = true;
                if (fileSave.ShowDialog() == DialogResult.OK)
                {
                    if (!fileSave.FileName.Contains(".xlsx"))
                    {
                        XtraMessageBox.Show("File save phải định dạng .xlsx", "Thông Báo");
                    }
                    else
                    {
                        //System.IO.File.Copy(PathFile, fileSave.FileName, true);
                        pathFileSave = fileSave.FileName;
                    }
                }
                else
                {
                    return;
                }

                string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByStore?sql_Exec=" + "sp_Get_Product_Export";
                var    json  = API.API_GET(sLink);

                var       jsondata = JObject.Parse(json).GetValue("Data");
                DataTable dt       = (DataTable)JsonConvert.DeserializeObject(jsondata.ToString(), (typeof(DataTable)));
                string    Folder   = AppDomain.CurrentDomain.BaseDirectory + "/AppData";
                if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "/AppData"))
                {
                    Directory.CreateDirectory(Folder);
                }

                Folder = AppDomain.CurrentDomain.BaseDirectory + string.Format("/AppData/{0}/", DateTime.Now.ToString("yyyyMMdd"));
                if (!Directory.Exists(Folder))
                {
                    Directory.CreateDirectory(Folder);
                }

                #region Xóa File cũ
                System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "/AppData/");
                foreach (System.IO.DirectoryInfo di in dir.GetDirectories())
                {
                    if (di.Name != DateTime.Today.ToString("yyyyMMdd"))
                    {
                        System.IO.Directory.Delete(di.FullName, true);
                    }
                }
                #endregion Xóa File cũ

                string PathFile = Folder + string.Format("/ExportData_{0}.xlsx", DateTime.Now.ToString("ddMMyyyyHHmmss"));
                using (WebClient webClient = new WebClient())
                {
                    webClient.DownloadFile(new Uri(Form_Main.URL_API + "/Uploads/Tmp/template/template.xlsx"), PathFile);
                }

                System.IO.FileInfo fnew = new System.IO.FileInfo(PathFile);
                using (ExcelPackage pck = new ExcelPackage(fnew))
                {
                    ExcelWorksheet ws = pck.Workbook.Worksheets["Sheet1"];
                    if (ws == null)
                    {
                        ws = pck.Workbook.Worksheets.Add("Sheet1");
                    }
                    ws.Cells["A2"].LoadFromDataTable(dt, false);
                    pck.Save();
                }
                System.IO.File.Copy(PathFile, fileSave.FileName, true);

                if (File.Exists(PathFile))
                {
                    File.Delete(PathFile);
                }
                try
                {
                    Process.Start(fileSave.FileName);
                }
                catch
                {
                    XtraMessageBox.Show("Bạn cần cài đặt Excel để mở file!", "Thông Báo");
                }
                btnExport.Enabled = true;
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Product", "ExportData()", ex.ToString()));
                btnExport.Enabled = true;
                return;
            }
        }