Ejemplo n.º 1
0
        private void searchSanPham_CloseUp(object sender, DevExpress.XtraEditors.Controls.CloseUpEventArgs e)
        {
            int focus = dgvDetails.FocusedRowHandle;

            if (focus >= 0)
            {
                SearchLookUpEdit edit = sender as SearchLookUpEdit;
                if (e.AcceptValue)
                {
                    ProductSelect row = (edit.Properties.GetRowByKeyValue(e.Value) as ProductSelect);
                    dgvDetails.SetFocusedRowCellValue("ProductCode", row.ProductCode.ToString());
                    dgvDetails.SetFocusedRowCellValue("ID", row.ID.ToString());
                    dgvDetails.SetFocusedRowCellValue("ProductName", row.ProductName.ToString());
                    dgvDetails.SetFocusedRowCellValue("Price", row.Price.ToString());

                    focus = dgv_Main.FocusedRowHandle;
                    if (focus >= 0)
                    {
                        dgv_Main.SetFocusedRowCellValue("TongTien", listdetails.Sum(o => o.ThanhTien));
                        dgv_Main.BestFitColumns(true);
                    }
                    dgvDetails.BestFitColumns(true);
                }
            }
        }
Ejemplo n.º 2
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());
                DataTable            dt     = SQLHelper.ExecuteDataTable("sp_Get_Product_Select");
                List <ProductSelect> listob = new List <ProductSelect>();
                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();;
                    string        Description = dt.Rows[i]["Description"].ToString();;
                    decimal       Price       = decimal.Parse(dt.Rows[i]["Price"].ToString());
                    ProductSelect ob          = new ProductSelect(ID, ProductCode, ProductName, Description, Price);
                    listob.Add(ob);
                }
                searchSanPham.DataSource = listob;
            }
            catch (Exception ex)
            {
                API.API_ERRORLOG(new ERRORLOG(Form_Main.IPAddress, "Form_ProductGroup", "LoadInfoProduct()", ex.ToString()));
            }
        }