private void grvHistory_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e) { GridView view = sender as GridView; MaterialHistoryModel model = (MaterialHistoryModel)MaterialHistoryBO.Instance.FindByPK(TextUtils.ToInt(view.GetRowCellValue(e.RowHandle, colID))); model.Qty = TextUtils.ToDecimal(view.GetRowCellValue(e.RowHandle, colQty)); MaterialHistoryBO.Instance.Update(model); }
void save() { if (grvHistory.RowCount == 0) { return; } for (int i = 0; i < grvHistory.RowCount; i++) { try { int id = TextUtils.ToInt(grvHistory.GetRowCellValue(i, colID)); MaterialHistoryModel model = (MaterialHistoryModel)MaterialHistoryBO.Instance.FindByPK(id); model.Qty = TextUtils.ToDecimal(grvHistory.GetRowCellValue(i, colQty)); MaterialHistoryBO.Instance.Update(model); } catch { } } }
protected MaterialHistoryFacade(MaterialHistoryModel model) : base(model) { }
private void grdData_DragDrop(object sender, DragEventArgs e) { try { if (cboModule.EditValue == null) { MessageBox.Show("Bạn hãy chọn một thiết kế!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (dtOne.Rows.Count == 0) { MessageBox.Show("Bạn hãy nhập thông số yêu cầu!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DataRow row = e.Data.GetData(typeof(DataRow)) as DataRow; try { DataTable dt = TextUtils.Select("vDMVTC", new Expression("ProductCode", TextUtils.ToInt(cboModule.EditValue)) .And(new Expression("MaterialID", TextUtils.ToInt(row["ID"])))); if (dt.Rows.Count > 0) { MessageBox.Show("Vật tư này đã được chọn!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } } catch (Exception) { } int moduleID = ((ModulesModel)(ModulesBO.Instance.FindByAttribute("Code", cboModule.EditValue.ToString()))[0]).ID; if (moduleID == 0) { MessageBox.Show("Module chưa có trong quản lý thiết kế!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } string valueTT = ""; string nameTS = ""; for (int i = 0; i < dtAllMaterial.Columns.Count; i++) { if (i > 6) { nameTS += dtAllMaterial.Columns[i].Caption + "@"; valueTT += row[i].ToString() + "@"; } } string valueYC = ""; for (int i = 0; i < dtOne.Columns.Count; i++) { if (i > 6) { valueYC += dtOne.Rows[0][i].ToString() + "@"; } } MaterialHistoryModel model = new MaterialHistoryModel(); model.MaterialID = TextUtils.ToInt(row["ID"]); model.ModuleID = moduleID; //TextUtils.ToInt(cboModule.EditValue); model.Price = TextUtils.ToDecimal(row["Price"]); model.Qty = 1; model.Delivery = TextUtils.ToDecimal(row["DeliveryPeriod"]); model.ValueTT = valueTT.Substring(0, valueTT.Length - 1); model.ValueYC = valueYC.Substring(0, valueYC.Length - 1); model.NameTS = nameTS.Substring(0, nameTS.Length - 1); MaterialHistoryBO.Instance.Insert(model); loadHistory(); } catch (Exception ex) { TextUtils.ShowError(ex); } }