private void TaoMoi()
 {
     try
     {
         IDGroup = "0";
         ProductGroupHeader ob = new ProductGroupHeader();
         ob.ProductGroupName = txtTenNhom.Text;
         ob.CreateBy         = Form_Main.user.Username;
         if (listHeader == null)
         {
             listHeader = new List <ProductGroupHeader>();
         }
         listHeader.Add(ob);
         dgc_Main.DataSource = listHeader;
         dgv_Main.RefreshData();
         dgv_Main.BestFitColumns(true);
         ProductGroupDetails obd = new ProductGroupDetails();
         listdetails = new List <ProductGroupDetails>();
         obd.SoLuong = 1;
         listdetails.Add(obd);
         dgcDetails.DataSource = listdetails;
         dgvDetails.RefreshData();
         dgvDetails.BestFitColumns(true);
     }
     catch (Exception ex)
     {
         API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Login", "TaoMoi()", ex.ToString()));
     }
 }
 /// <summary>
 /// xóa tay từng line
 /// </summary>
 private void DeleteDetails()
 {
     try
     {
         // Create an empty list.
         int focus = dgvDetails.FocusedRowHandle;
         if (focus >= 0)
         {
             ProductGroupDetails dr = (ProductGroupDetails)dgvDetails.GetFocusedRow();
             if (dr != null)
             {
                 listdetails.Remove(dr);
                 dgcDetails.DataSource = listdetails;
                 dgvDetails.RefreshData();
             }
             focus = dgv_Main.FocusedRowHandle;
             if (focus >= 0)
             {
                 dgv_Main.SetFocusedRowCellValue("TongTien", listdetails.Sum(o => o.ThanhTien));
             }
         }
     }
     catch (Exception ex)
     {
         API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Login", "DeleteDetails()", ex.ToString()));
     }
 }
 /// <summary>
 /// Sự kiện Selected Row
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 ///
 private void SelectedRow()
 {
     try
     {
         int focus = dgv_Main.FocusedRowHandle;
         if (focus >= 0)
         {
             ProductGroupHeader ob = (ProductGroupHeader)dgv_Main.GetFocusedRow();
             if (ob != null)
             {
                 IDGroup         = ob.ID;
                 txtTenNhom.Text = ob.ProductGroupName.ToString();
                 string DSSanPham = ob.ListProductCode.ToString();
                 LoadInfoProductDetails(DSSanPham);
             }
         }
     }
     catch
     {
         IDGroup = "0";
         ProductGroupDetails obd = new ProductGroupDetails();
         listdetails = new List <ProductGroupDetails>();
         obd.SoLuong = 1;
         listdetails.Add(obd);
         dgcDetails.DataSource = listdetails;
         dgvDetails.RefreshData();
         dgvDetails.BestFitColumns(true);
     }
 }
        /// <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()));
            }
        }
Exemple #5
0
        private void TaoMoi()
        {
            IDGroup = "0";
            ProductGroupHeader ob = new ProductGroupHeader();

            ob.ProductGroupName = txtTenNhom.Text;
            ob.CreateBy         = Form_Main.user.Username;
            listHeader.Add(ob);
            dgc_Main.DataSource = listHeader;
            dgv_Main.RefreshData();
            dgv_Main.BestFitColumns(true);
            ProductGroupDetails obd = new ProductGroupDetails();

            listdetails = new List <ProductGroupDetails>();
            obd.SoLuong = 1;
            listdetails.Add(obd);
            dgcDetails.DataSource = listdetails;
            dgvDetails.RefreshData();
            dgvDetails.BestFitColumns(true);
        }
 private void thêmSảnPhẩmToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         ProductGroupDetails ob = listdetails.Find(o => o.ID == "");
         if (ob != null)
         {
             XtraMessageBox.Show("Bạn đã có 1 dòng trống chưa thao tác vui lòng cập nhật trên dòng đó", "Thông Báo");
             return;
         }
         ob = new ProductGroupDetails();
         listdetails.Add(ob);
         dgcDetails.DataSource = listdetails;
         ob.SoLuong            = 1;
         dgvDetails.RefreshData();
         dgvDetails.BestFitColumns(true);
     }
     catch (Exception ex)
     {
         API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Login", "thêmSảnPhẩmToolStripMenuItem_Click()", ex.ToString()));
     }
 }
 /// <summary>
 /// Xóa nhiều dòng
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 ///
 private void XoaNhieuLine()
 {
     try
     {
         List <ProductGroupDetails> lstdel = new List <ProductGroupDetails>();
         // Add the selected rows to the list.
         for (int i = 0; i < dgvDetails.SelectedRowsCount; i++)
         {
             ProductGroupDetails ob = (ProductGroupDetails)dgvDetails.GetRow(dgvDetails.GetSelectedRows()[i]);
             lstdel.Add(ob);
         }
         if (dgvDetails.SelectedRowsCount == 0)
         {
             XtraMessageBox.Show("Không có thông tin nào được chọn để xóa! Vui lòng chọn dữ liệu để thao tác", "Thông Tin");
             return;
         }
         else
         {
             foreach (ProductGroupDetails item in lstdel)
             {
                 listdetails.Remove(item);
             }
             dgvDetails.RefreshData();
             dgvDetails.BestFitColumns(true);
         }
         int focus = dgv_Main.FocusedRowHandle;
         if (focus >= 0)
         {
             dgv_Main.SetFocusedRowCellValue("TongTien", listdetails.Sum(o => o.ThanhTien));
         }
     }
     catch (Exception ex)
     {
         API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_Login", "XoaNhieuLine()", ex.ToString()));
     }
 }