private void DBGrid_DoubleClick(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (DBGrid.CurrentRow == null) { return; } modWarehouseInoutForm mod = (modWarehouseInoutForm)DBGrid.CurrentRow.DataBoundItem; EditWarehouseInout frm = new EditWarehouseInout(); frm.EditItem(mod.Id); if (frm.ShowDialog() == DialogResult.OK) { LoadData(); } } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }
/// <summary> /// insert a warehouseinoutform /// <summary> /// <param name=mod>model object of warehouseinoutform</param> /// <param name=out emsg>return error message</param> /// <returns>true/false</returns> public bool Insert(modWarehouseInoutForm mod, out string emsg) { try { dalWarehouseInoutType daltype = new dalWarehouseInoutType(); modWarehouseInoutType modtype = daltype.GetItem(mod.InoutType, out emsg); string sql = string.Format("insert into warehouse_inout_form(inout_type,inout_flag,inout_date,status,warehouse_id,product_id,product_name,size,qty,price,remark,update_user,update_time,no)values('{0}',{1},'{2}',{3},'{4}','{5}','{6}',{7},{8},{9},'{10}','{11}',getdate(),'{12}')", mod.InoutType, modtype.InoutFlag, mod.InoutDate, mod.Status, mod.WarehouseId, mod.ProductId, mod.ProductName, mod.Size, mod.Qty, mod.CostPrice, mod.Remark, mod.UpdateUser, mod.No); int i = SqlHelper.ExecuteNonQuery(sql); if (i > 0) { emsg = null; return(true); } else { emsg = "Unknown error when ExecuteNonQuery!"; return(false); } } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(false); } }
/// <summary> /// update a warehouseinoutform /// <summary> /// <param name=id>id</param> /// <param name=mod>model object of warehouseinoutform</param> /// <param name=out emsg>return error message</param> /// <returns>true/false</returns> public bool Update(int id, modWarehouseInoutForm mod, out string emsg) { try { dalWarehouseInoutType daltype = new dalWarehouseInoutType(); modWarehouseInoutType modtype = daltype.GetItem(mod.InoutType, out emsg); string sql = string.Format("update warehouse_inout_form set inout_type='{0}',inout_flag={1},inout_date='{2}',status={3},warehouse_id='{4}',product_id='{5}',product_name='{6}',size={7},qty={8},price={9},remark='{10}',no='{11}',price_status={12} where id={13}", mod.InoutType, modtype.InoutFlag, mod.InoutDate, mod.Status, mod.WarehouseId, mod.ProductId, mod.ProductName, mod.Size, mod.Qty, mod.CostPrice, mod.Remark, mod.No, 0, id); int i = SqlHelper.ExecuteNonQuery(sql); if (i > 0) { emsg = null; return(true); } else { emsg = "Unknown error when ExecuteNonQuery!"; return(false); } } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(false); } }
public void EditItem(int id) { try { this.Cursor = Cursors.WaitCursor; _action = "EDIT"; FillControl.FillWarehouseInoutType(cboInoutType, 0, false, true); modWarehouseInoutForm mod = _dal.GetItem(id, out Util.emsg); if (mod != null) { txtId.Text = id.ToString(); dtpInoutDate.Value = mod.InoutDate; cboInoutType.SelectedValue = mod.InoutType; txtNo.Text = mod.No; txtProductId.Text = mod.ProductId; txtProductName.Text = mod.ProductName; txtSize.Text = mod.Size.ToString(); txtQty.Text = mod.Qty.ToString(); txtWarehouseId.Text = mod.WarehouseId.ToString(); txtRemark.Text = mod.Remark; if (mod.Status == 1) { status4.Image = Properties.Resources.audited; Util.ChangeStatus(this, true); toolSave.Enabled = false; } else { status4.Image = null; toolSave.Visible = true; Util.ChangeStatus(this, false); txtId.ReadOnly = true; toolSave.Enabled = true; } dalProductList dalpdt = new dalProductList(); modProductList modpdt = dalpdt.GetItem(mod.ProductId, out Util.emsg); if (modpdt.SizeFlag == 1) { txtSize.Enabled = true; } else { txtSize.Enabled = false; } } } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }
/// <summary> /// get new credence list /// <summary> /// <param name=fromdate>fromdate</param> /// <param name=todate>todate</param> /// <param name=out emsg>return error message</param> ///<returns>details of all salesshipment</returns> public BindingCollection <modWarehouseInoutForm> GetWaitCredenceList(string fromdate, string todate, out string emsg) { try { BindingCollection <modWarehouseInoutForm> modellist = new BindingCollection <modWarehouseInoutForm>(); //Execute a query to read the categories string inoutdatewhere = string.Empty; if (!string.IsNullOrEmpty(fromdate)) { inoutdatewhere = "and a.inout_date >= '" + Convert.ToDateTime(fromdate) + "' "; } if (!string.IsNullOrEmpty(todate)) { inoutdatewhere += "and a.inout_date <= '" + Convert.ToDateTime(todate) + "' "; } string sql = "select id,inout_type,inout_flag,inout_date,no,status,price_status,warehouse_id,product_id,product_name,size,qty,price,remark,update_user,update_time,audit_man,audit_time,acc_name,acc_seq " + "from warehouse_inout_form a where a.status=1 and a.price_status=1 and (a.acc_name is null or a.acc_name='') and a.acc_seq=0 " + inoutdatewhere + " order by id desc"; using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { while (rdr.Read()) { modWarehouseInoutForm model = new modWarehouseInoutForm(); model.Id = dalUtility.ConvertToInt(rdr["id"]); model.InoutType = dalUtility.ConvertToString(rdr["inout_type"]); model.InoutFlag = dalUtility.ConvertToInt(rdr["inout_flag"]); model.InoutDate = dalUtility.ConvertToDateTime(rdr["inout_date"]); model.No = dalUtility.ConvertToString(rdr["no"]); model.Status = dalUtility.ConvertToInt(rdr["status"]); model.PriceStatus = dalUtility.ConvertToInt(rdr["price_status"]); model.WarehouseId = dalUtility.ConvertToString(rdr["warehouse_id"]); model.ProductId = dalUtility.ConvertToString(rdr["product_id"]); model.ProductName = dalUtility.ConvertToString(rdr["product_name"]); model.Size = dalUtility.ConvertToDecimal(rdr["size"]); model.Qty = dalUtility.ConvertToDecimal(rdr["qty"]); model.CostPrice = dalUtility.ConvertToDecimal(rdr["price"]); model.Remark = dalUtility.ConvertToString(rdr["remark"]); model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]); model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_time"]); model.AuditMan = dalUtility.ConvertToString(rdr["audit_man"]); model.AuditTime = dalUtility.ConvertToDateTime(rdr["audit_time"]); model.AccName = dalUtility.ConvertToString(rdr["acc_name"]); model.AccSeq = dalUtility.ConvertToInt(rdr["acc_seq"]); modellist.Add(model); } } emsg = null; return(modellist); } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(null); } }
/// <summary> /// audit warehouse inout /// <summary> /// <param name=id>id</param> /// <param name=updateuser>updateuser</param> /// <param name=out emsg>return error message</param> /// <returns>true/false</returns> public bool Audit(int id, string updateuser, out string emsg) { string sql = string.Empty; SqlConnection conn = SqlHelper.getConn(); conn.Open(); SqlTransaction trans = conn.BeginTransaction(); SqlCommand cmd = new SqlCommand(); try { modWarehouseInoutForm mod = GetItem(id, out emsg); if (mod.Status == 1) { emsg = "这张单据已经审核,您无须再审"; return(false); } if (mod.InoutFlag == 1) { sql = string.Format("insert into warehouse_product_inout(warehouse_id,product_id,size,form_id,form_type,inv_no,inout_date,start_qty,input_qty,output_qty,remark,update_user,update_time)values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}',getdate())", mod.WarehouseId, mod.ProductId, mod.Size, id, mod.InoutType, mod.No, mod.InoutDate, 0, mod.Qty, 0, mod.Remark, updateuser); } else { sql = string.Format("insert into warehouse_product_inout(warehouse_id,product_id,size,form_id,form_type,inv_no,inout_date,start_qty,input_qty,output_qty,remark,update_user,update_time)values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}',getdate())", mod.WarehouseId, mod.ProductId, mod.Size, id, mod.InoutType, mod.No, mod.InoutDate, 0, 0, mod.Qty, mod.Remark, updateuser); } SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null); cmd.ExecuteNonQuery(); sql = string.Format("update warehouse_inout_form set status={0},audit_man='{1}',audit_time=getdate() where id='{2}'", 1, updateuser, id); SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null); cmd.ExecuteNonQuery(); trans.Commit(); emsg = string.Empty; return(true); } catch (Exception ex) { trans.Rollback(); emsg = dalUtility.ErrorMessage(ex.Message); return(false); } finally { trans.Dispose(); cmd.Dispose(); if (conn.State != ConnectionState.Closed) { conn.Dispose(); } } }
/// <summary> /// get table record /// <summary> /// <param name=id>id</param> /// <param name=out emsg>return error message</param> ///<returns>get a record detail of warehouseinoutform</returns> public modWarehouseInoutForm GetItem(int id, out string emsg) { try { //Execute a query to read the categories string sql = string.Format("select id,inout_type,inout_flag,inout_date,no,status,price_status,warehouse_id,product_id,product_name,size,qty,price,remark,update_user,update_time,audit_man,audit_time,acc_name,acc_seq from warehouse_inout_form where id={0} order by id", id); using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { if (rdr.Read()) { modWarehouseInoutForm model = new modWarehouseInoutForm(); model.Id = dalUtility.ConvertToInt(rdr["id"]); model.InoutType = dalUtility.ConvertToString(rdr["inout_type"]); model.InoutFlag = dalUtility.ConvertToInt(rdr["inout_flag"]); model.InoutDate = dalUtility.ConvertToDateTime(rdr["inout_date"]); model.No = dalUtility.ConvertToString(rdr["no"]); model.Status = dalUtility.ConvertToInt(rdr["status"]); model.PriceStatus = dalUtility.ConvertToInt(rdr["price_status"]); model.WarehouseId = dalUtility.ConvertToString(rdr["warehouse_id"]); model.ProductId = dalUtility.ConvertToString(rdr["product_id"]); model.ProductName = dalUtility.ConvertToString(rdr["product_name"]); model.Size = dalUtility.ConvertToDecimal(rdr["size"]); model.Qty = dalUtility.ConvertToDecimal(rdr["qty"]); model.CostPrice = dalUtility.ConvertToDecimal(rdr["price"]); model.Remark = dalUtility.ConvertToString(rdr["remark"]); model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]); model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_time"]); model.AuditMan = dalUtility.ConvertToString(rdr["audit_man"]); model.AuditTime = dalUtility.ConvertToDateTime(rdr["audit_time"]); model.AccName = dalUtility.ConvertToString(rdr["acc_name"]); model.AccSeq = dalUtility.ConvertToInt(rdr["acc_seq"]); emsg = null; return(model); } else { emsg = "Error on read data"; return(null); } } } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(null); } }
/// <summary> /// get all warehouseinoutform /// <summary> /// <param name=accname>accname</param> /// <param name=accseq>accseq</param> /// <param name=out emsg>return error message</param> ///<returns>details of all warehouseinoutform</returns> public BindingCollection <modWarehouseInoutForm> GetIList(string accname, int?accseq, out string emsg) { try { BindingCollection <modWarehouseInoutForm> modellist = new BindingCollection <modWarehouseInoutForm>(); //Execute a query to read the categories string sql = string.Format("select id,inout_type,inout_flag,inout_date,no,status,price_status,warehouse_id,product_id,product_name,size,qty,price,remark,update_user,update_time,audit_man,audit_time,acc_name,acc_seq from warehouse_inout_form where acc_name='{0}' and acc_seq={1} order by id", accname, accseq); using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { while (rdr.Read()) { modWarehouseInoutForm model = new modWarehouseInoutForm(); model.Id = dalUtility.ConvertToInt(rdr["id"]); model.InoutType = dalUtility.ConvertToString(rdr["inout_type"]); model.InoutFlag = dalUtility.ConvertToInt(rdr["inout_flag"]); model.InoutDate = dalUtility.ConvertToDateTime(rdr["inout_date"]); model.No = dalUtility.ConvertToString(rdr["no"]); model.Status = dalUtility.ConvertToInt(rdr["status"]); model.PriceStatus = dalUtility.ConvertToInt(rdr["price_status"]); model.WarehouseId = dalUtility.ConvertToString(rdr["warehouse_id"]); model.ProductId = dalUtility.ConvertToString(rdr["product_id"]); model.ProductName = dalUtility.ConvertToString(rdr["product_name"]); model.Size = dalUtility.ConvertToDecimal(rdr["size"]); model.Qty = dalUtility.ConvertToDecimal(rdr["qty"]); model.CostPrice = dalUtility.ConvertToDecimal(rdr["price"]); model.Remark = dalUtility.ConvertToString(rdr["remark"]); model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]); model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_time"]); model.AuditMan = dalUtility.ConvertToString(rdr["audit_man"]); model.AuditTime = dalUtility.ConvertToDateTime(rdr["audit_time"]); model.AccName = dalUtility.ConvertToString(rdr["acc_name"]); model.AccSeq = dalUtility.ConvertToInt(rdr["acc_seq"]); modellist.Add(model); } } emsg = null; return(modellist); } catch (Exception ex) { emsg = dalUtility.ErrorMessage(ex.Message); return(null); } }
/// <summary> /// reset warehouse inout /// <summary> /// <param name=id>id</param> /// <param name=updateuser>updateuser</param> /// <param name=out emsg>return error message</param> /// <returns>true/false</returns> public bool Reset(int id, string updateuser, out string emsg) { string sql = string.Empty; SqlConnection conn = SqlHelper.getConn(); conn.Open(); SqlTransaction trans = conn.BeginTransaction(); SqlCommand cmd = new SqlCommand(); try { modWarehouseInoutForm mod = GetItem(id, out emsg); if (mod.Status == 0) { emsg = "这张单据尚未审核,您无须重置"; return(false); } sql = string.Format("delete warehouse_product_inout where form_id='{0}' and form_type='{1}'", id, mod.InoutType); SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null); cmd.ExecuteNonQuery(); sql = string.Format("update warehouse_inout_form set status={0},audit_man='{1}',audit_time=null where id='{2}'", 0, updateuser, id); SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null); cmd.ExecuteNonQuery(); trans.Commit(); emsg = string.Empty; return(true); } catch (Exception ex) { trans.Rollback(); emsg = dalUtility.ErrorMessage(ex.Message); return(false); } finally { trans.Dispose(); cmd.Dispose(); if (conn.State != ConnectionState.Closed) { conn.Dispose(); } } }
private void toolDel_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (DBGrid.CurrentRow == null) { return; } if (MessageBox.Show(clsTranslate.TranslateString("Do you really want to delete it?"), clsTranslate.TranslateString("Confirm"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } modWarehouseInoutForm mod = _dal.GetItem(Convert.ToInt32(DBGrid.CurrentRow.Cells[0].Value), out Util.emsg); if (mod.Status == 1) { MessageBox.Show("该单据已审核,您不能删除!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } bool ret = _dal.Delete(mod.Id, out Util.emsg); if (ret) { LoadData(); } else { MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }
private void toolPrice_Click(object sender, EventArgs e) { if (DBGrid.CurrentRow == null) { return; } modWarehouseInoutForm mod = (modWarehouseInoutForm)DBGrid.CurrentRow.DataBoundItem; if (mod.AccSeq > 0) { MessageBox.Show("该单据已做凭证,不可修改单价!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } decimal price = mod.CostPrice; if (price == 0) { price = clsLxms.GetPrice(mod.ProductId); } frmInputBox frm = new frmInputBox("请输入产品的成本价格:", price.ToString()); if (frm.ShowDialog() == DialogResult.OK) { bool ret = _dal.UpdatePrice(mod.Id, Convert.ToDecimal(Util.retValue1), out Util.emsg); if (ret) { DBGrid.CurrentRow.Cells["CostPrice"].Value = Convert.ToDecimal(Util.retValue1); DBGrid.CurrentRow.Cells["PriceStatus"].Value = 1; DBGrid.CurrentRow.DefaultCellStyle.ForeColor = Color.DarkGray; } else { MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
private void toolSave_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (dtpInoutDate.Value < Util.modperiod.StartDate) { MessageBox.Show("该日期的数据已锁定,不能更新数据!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); dtpInoutDate.Focus(); return; } if (cboInoutType.SelectedValue == null || string.IsNullOrEmpty(cboInoutType.SelectedValue.ToString())) { MessageBox.Show(clsTranslate.TranslateString("Inout Type") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboInoutType.Focus(); return; } if (string.IsNullOrEmpty(txtSize.Text.Trim())) { MessageBox.Show(clsTranslate.TranslateString("Size") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtSize.Focus(); return; } else if (!Util.IsNumeric(txtSize.Text)) { MessageBox.Show(clsTranslate.TranslateString("Size") + clsTranslate.TranslateString(" must be a numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtSize.Focus(); return; } else if (Convert.ToDecimal(txtSize.Text.Trim()) <= 0) { MessageBox.Show(clsTranslate.TranslateString("Size") + clsTranslate.TranslateString(" must > 0!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtSize.Focus(); return; } if (string.IsNullOrEmpty(txtQty.Text.Trim())) { MessageBox.Show(clsTranslate.TranslateString("Qty") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtQty.Focus(); return; } else if (!Util.IsNumeric(txtQty.Text)) { MessageBox.Show(clsTranslate.TranslateString("Qty") + clsTranslate.TranslateString(" must be a numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtQty.Focus(); return; } else if (Convert.ToDecimal(txtQty.Text.Trim()) <= 0) { MessageBox.Show(clsTranslate.TranslateString("Qty") + clsTranslate.TranslateString(" must > 0!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtQty.Focus(); return; } if (string.IsNullOrEmpty(txtProductId.Text)) { MessageBox.Show(clsTranslate.TranslateString("Product Id") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtProductId.Focus(); return; } if (string.IsNullOrEmpty(txtProductId.Text)) { MessageBox.Show(clsTranslate.TranslateString("Product Id") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtProductId.Focus(); return; } if (string.IsNullOrEmpty(txtWarehouseId.Text)) { MessageBox.Show(clsTranslate.TranslateString("Warehouse id") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtWarehouseId.Focus(); return; } if (clsLxms.GetParameterValue("NEED_INOUT_NO").CompareTo("T") == 0 && string.IsNullOrEmpty(txtNo.Text)) { MessageBox.Show(clsTranslate.TranslateString("No") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtNo.Focus(); return; } modWarehouseInoutForm mod = new modWarehouseInoutForm(); mod.Id = Convert.ToInt32(txtId.Text); mod.InoutDate = dtpInoutDate.Value; mod.InoutType = cboInoutType.SelectedValue.ToString(); mod.No = txtNo.Text.Trim(); mod.ProductId = txtProductId.Text.Trim(); mod.ProductName = txtProductName.Text.Trim(); if (clsLxms.GetProductSizeFlag(mod.ProductId) == 0) { mod.Size = 1; } else { mod.Size = Convert.ToDecimal(txtSize.Text); } mod.Qty = Convert.ToDecimal(txtQty.Text); mod.CostPrice = clsLxms.GetPrice(mod.ProductId); mod.WarehouseId = txtWarehouseId.Text.Trim(); mod.Remark = txtRemark.Text.Trim(); mod.UpdateUser = Util.UserId; mod.Status = 0; bool ret; if (_action == "ADD" || _action == "NEW") { ret = _dal.Insert(mod, out Util.emsg); if (ret) { if (MessageBox.Show("保存成功,是否继续添加?", clsTranslate.TranslateString("Confirm"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { txtProductName.Tag = null; txtProductName.Text = string.Empty; txtSize.Text = string.Empty; txtQty.Text = string.Empty; txtRemark.Text = string.Empty; } else { this.DialogResult = DialogResult.OK; this.Dispose(); } } else { MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { ret = _dal.Update(mod.Id, mod, out Util.emsg); if (ret) { this.DialogResult = DialogResult.OK; this.Dispose(); } else { MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }
private void toolReset_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (DBGrid.RowCount == 0) { return; } if (DBGrid.SelectedRows.Count == 0 && DBGrid.CurrentRow == null) { return; } if (MessageBox.Show(clsTranslate.TranslateString("Do you really want to reset it?"), clsTranslate.TranslateString("Confirm"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } if (DBGrid.SelectedRows.Count == 0) { modWarehouseInoutForm mod = _dal.GetItem(Convert.ToInt32(DBGrid.CurrentRow.Cells[0].Value), out Util.emsg); if (mod.AccSeq > 0) { MessageBox.Show("该单据已做凭证,不可重置!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (_dal.Reset(mod.Id, Util.UserId, out Util.emsg)) { MessageBox.Show(clsTranslate.TranslateString("Reset Success!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); LoadData(); } else { MessageBox.Show(clsTranslate.TranslateString(Util.emsg), mod.Id.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } else { for (int i = DBGrid.SelectedRows.Count - 1; i >= 0; i--) { modWarehouseInoutForm mod = _dal.GetItem(Convert.ToInt32(DBGrid.SelectedRows[i].Cells[0].Value), out Util.emsg); if (mod.AccSeq > 0) { MessageBox.Show("该单据已做凭证,不可重置!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (_dal.Reset(mod.Id, Util.UserId, out Util.emsg)) { // } else { MessageBox.Show(clsTranslate.TranslateString(Util.emsg), mod.Id.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } LoadData(); } } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }