Пример #1
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);
                        SQLHelper.ExecuteDataTableByQuery(sql_Exect);
                    }
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_TimKiemBaoGia", "XoaBaoGia()", ex.ToString()));
            }
        }
Пример #2
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());
                listdetails = new List <ProductGroupDetails>();
                DataTable dt = SQLHelper.ExecuteDataTableByQuery(sqlQuery);
                if (dt != null && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string              ID          = dt.Rows[i]["ID"].ToString();
                        string              ProductCode = dt.Rows[i]["ProductCode"].ToString();
                        string              ProductName = dt.Rows[i]["ProductName"].ToString();
                        decimal             Price       = decimal.Parse(dt.Rows[i]["Price"].ToString());
                        int                 SoLuong     = int.Parse(dt.Rows[i]["SoLuong"].ToString());
                        ProductGroupDetails ob          = new ProductGroupDetails(ID, ProductCode, ProductName, Price, SoLuong);
                        listdetails.Add(ob);
                    }
                }
                dgcDetails.DataSource = listdetails;
                dgvDetails.BestFitColumns(true);
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_ProductGroup", "LoadInfoProductDetails()", ex.ToString()));
            }
        }
Пример #3
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;
                DataTable dt = SQLHelper.ExecuteDataTableByQuery(sql_exec);
                if (dt != null && dt.Rows.Count > 0)
                {
                    var Result  = dt.Rows[0]["Result"].ToString();  //jsondataChild.First.GetValue("Result").Value;
                    var Message = dt.Rows[0]["Message"].ToString(); // jsondataChild.First.GetValue("Message").Value;
                    if (Result == "1")
                    {
                        LoadInfoProductGroup();
                        listdetails           = null;
                        dgcDetails.DataSource = listdetails;
                        dgvDetails.RefreshData();
                    }
                    else
                    {
                        XtraMessageBox.Show(Message, "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                //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()));
            }
        }
Пример #4
0
        private void LoadDSPhanQuyenTheoTenNhom(string tennhom)
        {
            try
            {
                string sql_Exect = string.Format("Exec sp_GetDSChiTietPQ @TenNhom=N'{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)));
                DataTable dt = SQLHelper.ExecuteDataTableByQuery(sql_Exect);
                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()));
            }
        }
Пример #5
0
 void DeleteCompany()
 {
     try
     {
         if (DialogResult.Yes == XtraMessageBox.Show("Bạn có muốn xóa doanh nghiệp 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_Company_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");
                 DataTable dt = SQLHelper.ExecuteDataTableByQuery(sql_Exect);
                 if (dt != null && dt.Rows.Count > 0)
                 {
                     var Result  = dt.Rows[0]["Result"].ToString();
                     var Message = dt.Rows[0]["Message"].ToString();
                     if (Result == "1")//Login thành công
                     {
                         XtraMessageBox.Show(Message, "Thông Báo");
                         sp_Get_Company();
                         ClearForm();
                     }
                     else
                     {
                         XtraMessageBox.Show("Hủy Doanh Nghiệp Không Thành Công", "Thông Báo");
                     }
                 }
                 else
                 {
                     API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_DoanhNghiep", "DeleteCompany()", "Không có dữ liệu trả về"));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_DoanhNghiep", "DeleteCompany()", ex.ToString()));
     }
 }
Пример #6
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;
                DataTable dt = SQLHelper.ExecuteDataTableByQuery(sql_exec);
                if (dt != null && dt.Rows.Count > 0)
                {
                    var Result  = dt.Rows[0]["Result"].ToString();  //jsondataChild.First.GetValue("Result").Value;
                    var Message = dt.Rows[0]["Message"].ToString(); // jsondataChild.First.GetValue("Message").Value;
                    if (Result == "1")
                    {
                        XtraMessageBox.Show(Message, "Thông Báo");
                        LoadInfoProductGroup();
                    }
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_ProductGroup", "SaveProductGroup()", ex.ToString()));
            }
        }
Пример #7
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);
             SQLHelper.ExecuteDataTableByQuery(sql_Exect);
         }
     }
     catch (Exception ex)
     {
         API.API_ERRORLOG(new ERRORLOG(IPAddress, "Form_Main", "Logoff()", ex.ToString()));
     }
 }
Пример #8
0
        private void sp_Get_Customer()
        {
            try
            {
                string sql_Exect = string.Format("Exec sp_Get_ListCustomer_Search @Company={0}", chkLayALL.Checked? "0":idCompany);
                //string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect;
                //var json = API.API_GET_Rep(sLink);

                //var jsondata = JObject.Parse(json).GetValue("Data");
                //DataTable dt = (DataTable)JsonConvert.DeserializeObject(jsondata.ToString(), (typeof(DataTable)));
                DataTable dt = SQLHelper.ExecuteDataTableByQuery(sql_Exect);
                txtCustomer.Properties.DataSource = dt;
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Search_Customer", "sp_Get_Customer()", ex.ToString()));
            }
        }
Пример #9
0
 private void LoadEnquiryDetial(string ID_Enquiry)
 {
     try
     {
         string sql_Exect = string.Format("Exec sp_GetList_EnquiryDetails @ID_Enquiry={0}", ID_Enquiry);
         //string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect;
         //var json = API.API_GET_Rep(sLink);
         //var jsondata = JObject.Parse(json).GetValue("Data");
         //DataTable dt = (DataTable)JsonConvert.DeserializeObject(jsondata.ToString(), (typeof(DataTable)));
         DataTable dt = SQLHelper.ExecuteDataTableByQuery(sql_Exect);
         dgc_Main.DataSource = dt;
         dgv_Main.BestFitColumns(true);
     }
     catch (Exception ex)
     {
         API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Enquiry", "LoadEnquiryDetial()", ex.ToString()));
     }
 }
Пример #10
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;
                DataTable dt = SQLHelper.ExecuteDataTableByQuery("sp_extension_DeleteProduct");
                if (dt != null && dt.Rows.Count > 0)
                {
                    var Result  = dt.Rows[0]["Result"].ToString();
                    var Message = dt.Rows[0]["Message"].ToString();
                    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;
                }
                else
                {
                    API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Product", "btnDeleteAll_Click", "Không có dữ liệu trả về"));
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Product", "btnDeleteAll_Click", ex.ToString()));
            }
        }
Пример #11
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=N'{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)));
                DataTable dt = SQLHelper.ExecuteDataTableByQuery(sql_Exect);
                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()));
            }
        }
Пример #12
0
        private void sp_Get_Customer()
        {
            try
            {
                string sql_Exect = string.Format("Exec sp_Get_ListCustomer @Flag ='{0}' ", chkHienThi.Checked ? "1" : "0");
                //string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByQueryString?str_Query=" + sql_Exect;
                //var json = API.API_GET_Rep(sLink);

                //var jsondata = JObject.Parse(json).GetValue("Data");
                //DataTable dt = (DataTable)JsonConvert.DeserializeObject(jsondata.ToString(), (typeof(DataTable)));
                DataTable dt = SQLHelper.ExecuteDataTableByQuery(sql_Exect);
                dgc_Main.DataSource = dt;
                dgv_Main.BestFitColumns(true);
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Customer", "sp_Get_Customer()", ex.ToString()));
            }
        }
Пример #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=N'{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");
                    SQLHelper.ExecuteDataTableByQuery(sql_Exect);
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Frm_NhomQuyen", "HuyNhom()", ex.ToString()));
            }
        }
Пример #14
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;
                DataTable dt = SQLHelper.ExecuteDataTableByQuery(sql_Exect);
                if (dt != null && dt.Rows.Count > 0)
                {
                    var Result  = dt.Rows[0]["Result"].ToString();
                    var Message = dt.Rows[0]["Message"].ToString();
                    if (Result == "1")//Login thành công
                    {
                        XtraMessageBox.Show(Message, "Thông Báo");
                        LoadInfoProduct();
                    }
                    else
                    {
                        XtraMessageBox.Show(Message, "Thông Báo");
                    }
                }
                else
                {
                    API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Product", "XoaDuLieu()", "Không có dữ liệu trả về"));
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Product", "XoaDuLieu()", ex.ToString()));
            }
        }
Пример #15
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;

                DataTable dt = new DataTable();
                dt = SQLHelper.ExecuteDataTableByQuery(sql_Exect);
                if (dt != null && dt.Rows.Count > 0)
                {
                    var Result  = dt.Rows[0]["Result"].ToString();
                    var Message = dt.Rows[0]["Message"].ToString(); //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");
                    }
                }
                else
                {
                    API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Frm_NhomQuyen", "HuyTaiKhoan()", sql_Exect + "-Không có kết quả trả về"));
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Frm_NhomQuyen", "HuyTaiKhoan()", ex.ToString()));
            }
        }
Пример #16
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)));
            DataTable dt = SQLHelper.ExecuteDataTableByQuery(sql_Exect);

            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)));
            dt = SQLHelper.ExecuteDataTableByQuery(sql_Exect);
            cbbNhomQuyen.Properties.DataSource = dt;
        }
Пример #17
0
        private void LoadSoBaoGia()
        {
            try
            {
                //string sLink = Form_Main.URL_API + "/api/IPC247/sp_extension_GetDataByStore?sql_Exec=" + "sp_Quote_GenKey";
                //var json = API.API_GET_Rep(sLink);

                //var jsondata = JObject.Parse(json).GetValue("Data");
                //DataTable dt = (DataTable)JsonConvert.DeserializeObject(jsondata.ToString(), (typeof(DataTable)));
                DataTable dt = SQLHelper.ExecuteDataTableByQuery("sp_Quote_GenKey");
                if (dt != null && dt.Rows.Count > 0)
                {
                    txtTenBaoGia.Text = dt.Rows[0][0].ToString();
                }
                else
                {
                    API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Quote", "LoadSoBaoGia()", "không có data "));
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Quote", "LoadSoBaoGia()", ex.ToString()));
            }
        }
Пример #18
0
        private void LoadBaoGiaAll(string ID)
        {
            try
            {
                string sql_Exect = string.Format("Exec sp_GetQuote_To_Order " +
                                                 "@ID={0}, @IsHide={1}", ID, chkHide.Checked?"1":"0");
                DataTable dt = SQLHelper.ExecuteDataTableByQuery(sql_Exect);
                if (dt != null && dt.Rows.Count > 0)
                {
                    DateTime createOrder, PayOffDate;
                    if (dt.Rows[0]["CreateDate"].ToString() != "")
                    {
                        createOrder = DateTime.ParseExact(dt.Rows[0]["CreateDate"].ToString(), "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                        dte_CreateOrder.EditValue = createOrder;
                    }

                    txtContractNum.Text        = dt.Rows[0]["ContractNum"].ToString();
                    txt_Policy.Text            = dt.Rows[0]["DieuKhoan"].ToString();
                    txt_ProductCode.Text       = dt.Rows[0]["ProductCode"].ToString();
                    txtCardName.Text           = dt.Rows[0]["TenKH"].ToString();
                    txtAddress.Text            = dt.Rows[0]["DiaChi"].ToString();
                    txtContactPerson.Text      = dt.Rows[0]["ContractPerson"].ToString();
                    txtSum_CostPrice.EditValue = dt.Rows[0]["CostPrice"];
                    decimal.TryParse(dt.Rows[0]["SumPirceOfQuote"].ToString(), out PriceContract);
                    txt_PriceContract.EditValue = PriceContract;
                    txtSum_CostPrice.ToolTip    = string.Format("Tổng Giá Nhập Trên Hợp Đồng: {0}", dt.Rows[0]["SumCostPirceOfQuote"]);
                    txtSum_Price.Text           = dt.Rows[0]["TongTien"].ToString();
                    decimal CostPriceContract = 0;
                    decimal.TryParse(dt.Rows[0]["SumCostPirceOfQuote"].ToString(), out CostPriceContract);
                    txt_CostPriceContract.EditValue = CostPriceContract;
                    txtSum_Price.ToolTip            = string.Format("Tổng Giá Bán Trên Hợp Đồng: {0}", dt.Rows[0]["SumPirceOfQuote"]);
                    txtDeposit.EditValue            = dt.Rows[0]["Deposit"].ToString();
                    txt_DayDebt.EditValue           = dt.Rows[0]["DayDebt"];
                    if (dt.Rows[0]["ShipDate"].ToString() != "")
                    {
                        dte_ShipDate.EditValue = DateTime.ParseExact(dt.Rows[0]["ShipDate"].ToString(), "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                    }
                    slu_Paystatus.EditValue = dt.Rows[0]["PayStatus"];
                    slu_Saler.EditValue     = dt.Rows[0]["Sales"];
                    slu_Vendor.EditValue    = dt.Rows[0]["VendorCode"];
                    txt_PayNote.EditValue   = dt.Rows[0]["PayNote"].ToString();
                    txt_SaleNote.EditValue  = dt.Rows[0]["SalesNote"].ToString();
                    ID_CardCode             = dt.Rows[0]["IDCardCode"].ToString();
                    decimal.TryParse(dt.Rows[0]["Profit"].ToString(), out Profit);
                    IDOrder = dt.Rows[0]["IDOrder"].ToString();
                    string Flag_New  = dt.Rows[0]["Flag_New"].ToString();
                    string Flag_Edit = dt.Rows[0]["Flag_Edit"].ToString();
                    chk_Edit.Checked = Flag_Edit == "0" ? true : false;
                    chk_Edit.Enabled = !chk_Edit.Checked;
                    if (Flag_New == "0")
                    {
                        // XtraMessageBox.Show("Báo Giá Số này đã được tạo đơn hàng", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        lblStatus.Text      = "Đã Tạo Đơn Hàng";
                        lblStatus.ForeColor = Color.Red;
                    }
                    else
                    {
                        lblStatus.Text      = "Chưa Tạo Đơn Hàng";
                        lblStatus.ForeColor = Color.Green;
                    }
                    txt_Profit.EditValue = Profit;
                    if (dt.Rows[0]["PayOffDate"].ToString() != "")
                    {
                        PayOffDate = DateTime.ParseExact(dt.Rows[0]["PayOffDate"].ToString(), "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                        dte_PayOffDate.EditValue = PayOffDate;
                    }
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Frm_Manage_Order", "LoadBaoGiaAll", ex.ToString()));
            }
        }
Пример #19
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)));
                DataTable dt = SQLHelper.ExecuteDataTableByQuery(sql_Exect);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string base64 = dt.Rows[0][0].ToString();

                    var     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()));
                        }
                    }
                }
                else
                {
                    API.API_ERRORLOG(new ERRORLOG(IPAddress, "Form_Main", "LoadThongTinDefault()", sql_Exect + "\r\n Không lấy được thông tin"));
                }
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(IPAddress, "Form_Main", "LoadThongTinDefault()", ex.ToString()));
            }
        }
Пример #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)));
         DataTable dt = SQLHelper.ExecuteDataTableByQuery(sql_Exect);
         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()));
     }
 }