private bool GetBuy() { try { string text = TxtSearch.Text.Trim(); using (var context = new RubberSoftEntities()) { SetTime(); if (text == "") { var query = context.spt_GetBuy().Where(o => o.BuyDate >= StartDate && o.BuyDate <= EndDate).ToList(); GridBuy.DataSource = query; } else { var query = context.spt_GetBuy().Where(o => o.BuyDate >= StartDate && o.BuyDate <= EndDate && (o.BuyNumber.Contains(text) || o.CustomerName.Contains(text))).ToList(); GridBuy.DataSource = query; } } return(true); } catch (Exception ex) { XtraMessageBox.Show(ex.Message); return(false); } }
private bool GetBuyData(GridView view) { try { sBuyId = Convert.ToInt32(view.GetFocusedRowCellValue("BuyId")); using (var context = new RubberSoftEntities()) { var query = context.spt_GetBuy().Where(o => o.BuyId == sBuyId).ToList(); if (query.Count > 0) { foreach (spt_GetBuy_Result dt in query) { strBuyNumber = dt.BuyNumber; TxtBuyNumber.Text = dt.BuyNumber; DtBuyDate.DateTime = dt.BuyDate.Value; sCustomerId = dt.CustomerId.Value; TxtCustomerName.Text = dt.CustomerName; SpinSubTotal.Value = dt.SubTotal.Value; SpinDownValue.Value = dt.DownValue.Value; SpinNetTotal.Value = dt.NetTotal.Value; SpinSetOffValue.Value = dt.SetOffValue.Value; SpinValueBalance.Value = dt.ValueBalance.Value; sActive = dt.Active.Value; sProductTypeId = dt.ProductTypeId.Value; } GetCustomer(sCustomerId); GetBuyProduct(sBuyId); LoadProductType(sProductTypeId); GetValueBalance(sCustomerId); if (sActive == false) { BtnEditBuy.Enabled = false; //if (ClassProperty.IsOpenBuy == false) //{ // BtnRefBuy.Visible = true; //} } else { BtnEditBuy.Enabled = true; //BtnRefBuy.Visible = false; } } else { ClearData(); } } return(true); } catch (Exception ex) { XtraMessageBox.Show(ex.Message); return(false); } }
private bool CheckData(int id) { try { using (var context = new RubberSoftEntities()) { var query = context.spt_GetBuy().Where(o => o.BuyId == id).ToList(); if (query.Count > 0) { return(true); } else { return(false); } } } catch (Exception ex) { XtraMessageBox.Show(ex.Message); return(false); } }