private void toolEdit_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (DBGrid.CurrentRow == null) { return; } modAssetEvaluate mod = (modAssetEvaluate)DBGrid.CurrentRow.DataBoundItem; EditAssetEvaluate frm = new EditAssetEvaluate(); frm.EditItem(mod.FormId); 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> /// 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 <modAssetEvaluate> GetWaitCredenceList(string fromdate, string todate, out string emsg) { try { BindingCollection <modAssetEvaluate> modellist = new BindingCollection <modAssetEvaluate>(); //Execute a query to read the categories string formdatewhere = string.Empty; if (!string.IsNullOrEmpty(fromdate)) { formdatewhere = "and a.form_date >= '" + Convert.ToDateTime(fromdate) + "' "; } if (!string.IsNullOrEmpty(todate)) { formdatewhere += "and a.form_date <= '" + Convert.ToDateTime(todate) + "' "; } string sql = "select form_id,form_date,status,no,asset_id,asset_name,net_mny,evaluate_mny,remark,update_user,update_time,acc_name,acc_seq " + "from asset_evaluate a where a.status=1 and (a.acc_name is null or a.acc_name='') and a.acc_seq=0 " + formdatewhere + " order by form_id"; using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { while (rdr.Read()) { modAssetEvaluate model = new modAssetEvaluate(); model.FormId = dalUtility.ConvertToString(rdr["form_id"]); model.FormDate = dalUtility.ConvertToDateTime(rdr["form_date"]); model.Status = dalUtility.ConvertToInt(rdr["status"]); model.No = dalUtility.ConvertToString(rdr["no"]); model.AssetId = dalUtility.ConvertToString(rdr["asset_id"]); model.AssetName = dalUtility.ConvertToString(rdr["asset_name"]); model.NetMny = dalUtility.ConvertToDecimal(rdr["net_mny"]); model.EvaluateMny = dalUtility.ConvertToDecimal(rdr["evaluate_mny"]); model.Remark = dalUtility.ConvertToString(rdr["remark"]); model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]); model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_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); } }
public void EditItem(string formid) { try { this.Cursor = Cursors.WaitCursor; _action = "EDIT"; modAssetEvaluate mod = _dal.GetItem(formid, out Util.emsg); if (mod != null) { txtFormId.Text = formid; dtpFormDate.Value = mod.FormDate; txtNo.Text = mod.No; txtAssetId.Text = mod.AssetId; txtAssetName.Text = mod.AssetName; txtNetMny.Text = mod.NetMny.ToString(); txtEvaluateMny.Text = mod.EvaluateMny.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); txtFormId.ReadOnly = true; toolSave.Enabled = true; } txtAssetId.ReadOnly = true; txtAssetName.ReadOnly = true; txtNetMny.ReadOnly = true; } } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }
/// <summary> /// get table record /// <summary> /// <param name=formid>formid</param> /// <param name=out emsg>return error message</param> ///<returns>get a record detail of assetevaluate</returns> public modAssetEvaluate GetItem(string formid, out string emsg) { try { //Execute a query to read the categories string sql = string.Format("select form_id,form_date,status,no,asset_id,asset_name,net_mny,evaluate_mny,remark,update_user,update_time,acc_name,acc_seq from asset_evaluate where form_id='{0}' order by form_id", formid); using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { if (rdr.Read()) { modAssetEvaluate model = new modAssetEvaluate(); model.FormId = dalUtility.ConvertToString(rdr["form_id"]); model.FormDate = dalUtility.ConvertToDateTime(rdr["form_date"]); model.Status = dalUtility.ConvertToInt(rdr["status"]); model.No = dalUtility.ConvertToString(rdr["no"]); model.AssetId = dalUtility.ConvertToString(rdr["asset_id"]); model.AssetName = dalUtility.ConvertToString(rdr["asset_name"]); model.NetMny = dalUtility.ConvertToDecimal(rdr["net_mny"]); model.EvaluateMny = dalUtility.ConvertToDecimal(rdr["evaluate_mny"]); model.Remark = dalUtility.ConvertToString(rdr["remark"]); model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]); model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_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); } }
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; } modAssetEvaluate mod = _dal.GetItem(DBGrid.CurrentRow.Cells[0].Value.ToString(), out Util.emsg); if (mod.Status == 1) { MessageBox.Show("该单据已审核,您不能删除!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } bool ret = _dal.Delete(mod.FormId, 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; } }
/// <summary> /// update a assetevaluate /// <summary> /// <param name=formid>formid</param> /// <param name=mod>model object of assetevaluate</param> /// <param name=out emsg>return error message</param> /// <returns>true/false</returns> public bool Update(string formid, modAssetEvaluate mod, out string emsg) { try { string sql = string.Format("update asset_evaluate set form_date='{0}',status='{1}',no='{2}',asset_id='{3}',asset_name='{4}',net_mny={5},evaluate_mny={6},remark='{7}' where form_id='{8}'", mod.FormDate, mod.Status, mod.No, mod.AssetId, mod.AssetName, mod.NetMny, mod.EvaluateMny, mod.Remark, formid); 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> /// get all assetevaluate /// <summary> /// <param name=accname>accname</param> /// <param name=accseq>accseq</param> /// <param name=out emsg>return error message</param> ///<returns>details of all assetevaluate</returns> public BindingCollection <modAssetEvaluate> GetIList(string accname, int?accseq, out string emsg) { try { BindingCollection <modAssetEvaluate> modellist = new BindingCollection <modAssetEvaluate>(); //Execute a query to read the categories string sql = string.Format("select form_id,form_date,status,no,asset_id,asset_name,net_mny,evaluate_mny,remark,update_user,update_time,acc_name,acc_seq from asset_evaluate where acc_name='{0}' and acc_seq={1} order by form_id", accname, accseq); using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { while (rdr.Read()) { modAssetEvaluate model = new modAssetEvaluate(); model.FormId = dalUtility.ConvertToString(rdr["form_id"]); model.FormDate = dalUtility.ConvertToDateTime(rdr["form_date"]); model.Status = dalUtility.ConvertToInt(rdr["status"]); model.No = dalUtility.ConvertToString(rdr["no"]); model.AssetId = dalUtility.ConvertToString(rdr["asset_id"]); model.AssetName = dalUtility.ConvertToString(rdr["asset_name"]); model.NetMny = dalUtility.ConvertToDecimal(rdr["net_mny"]); model.EvaluateMny = dalUtility.ConvertToDecimal(rdr["evaluate_mny"]); model.Remark = dalUtility.ConvertToString(rdr["remark"]); model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]); model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_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> /// insert a assetevaluate /// <summary> /// <param name=mod>model object of assetevaluate</param> /// <param name=out emsg>return error message</param> /// <returns>true/false</returns> public bool Insert(modAssetEvaluate mod, out string emsg) { try { string formid = GetNewId(mod.FormDate); string sql = string.Format("insert into asset_evaluate(form_id,form_date,status,no,asset_id,asset_name,net_mny,evaluate_mny,remark,update_user,update_time)values('{0}','{1}','{2}','{3}','{4}','{5}',{6},{7},'{8}','{9}',getdate())", formid, mod.FormDate, mod.Status, mod.No, mod.AssetId, mod.AssetName, mod.NetMny, mod.EvaluateMny, mod.Remark, mod.UpdateUser); 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); } }
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) { modAssetEvaluate mod = _dal.GetItem(DBGrid.CurrentRow.Cells[0].Value.ToString(), out Util.emsg); if (mod.AccSeq > 0) { MessageBox.Show("该单据已做凭证,不可重置!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (_dal.Reset(mod.FormId, 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.FormId, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } else { for (int i = DBGrid.SelectedRows.Count - 1; i >= 0; i--) { modAssetEvaluate mod = _dal.GetItem(DBGrid.SelectedRows[i].Cells[0].Value.ToString(), out Util.emsg); if (mod.AccSeq > 0) { MessageBox.Show("该单据已做凭证,不可重置!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (_dal.Reset(mod.FormId, Util.UserId, out Util.emsg)) { DBGrid.SelectedRows[i].Cells["status"].Value = 0; DBGrid.SelectedRows[i].DefaultCellStyle.ForeColor = Color.Black; DBGrid.SelectedRows[i].Selected = false; } else { MessageBox.Show(clsTranslate.TranslateString(Util.emsg), mod.FormId, 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; } }
private void toolSave_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (dtpFormDate.Value < Util.modperiod.StartDate) { MessageBox.Show("该日期的数据已锁定,不能更新数据!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); dtpFormDate.Focus(); return; } if (string.IsNullOrEmpty(txtNetMny.Text.Trim())) { MessageBox.Show(clsTranslate.TranslateString("Net Mny") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtNetMny.Focus(); return; } else if (!Util.IsNumeric(txtNetMny.Text)) { MessageBox.Show(clsTranslate.TranslateString("Net Mny") + clsTranslate.TranslateString(" must be a numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtNetMny.Focus(); return; } if (string.IsNullOrEmpty(txtEvaluateMny.Text.Trim())) { MessageBox.Show(clsTranslate.TranslateString("Sale Mny") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtEvaluateMny.Focus(); return; } else if (!Util.IsNumeric(txtEvaluateMny.Text)) { MessageBox.Show(clsTranslate.TranslateString("Sale Mny") + clsTranslate.TranslateString(" must be a numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtEvaluateMny.Focus(); return; } if (string.IsNullOrEmpty(txtAssetName.Text)) { MessageBox.Show(clsTranslate.TranslateString("Asset name") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtAssetName.Focus(); return; } if (clsLxms.GetParameterValue("NEED_ASSET_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; } modAssetEvaluate mod = new modAssetEvaluate(); mod.FormId = txtFormId.Text; mod.FormDate = dtpFormDate.Value; mod.No = txtNo.Text.Trim(); mod.AssetId = txtAssetId.Text; mod.AssetName = txtAssetName.Text.Trim(); mod.NetMny = Convert.ToDecimal(txtNetMny.Text); mod.EvaluateMny = Convert.ToDecimal(txtEvaluateMny.Text); 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); } else { ret = _dal.Update(mod.FormId, 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; } }
/// <summary> /// get all asset sale /// <summary> /// <param name=statuslist>statuslist</param> /// <param name=formidlist>formidlist</param> /// <param name=assetidlist>assetidlist</param> /// <param name=assetname>assetname</param> /// <param name=fromdate>fromdate</param> /// <param name=todate>todate</param> /// <param name=out emsg>return error message</param> ///<returns>details of all assetadd</returns> public BindingCollection <modAssetEvaluate> GetIList(string statuslist, string formidlist, string assetidlist, string assetname, string fromdate, string todate, out string emsg) { try { string statuswhere = string.Empty; if (!string.IsNullOrEmpty(statuslist) && statuslist.CompareTo("ALL") != 0) { statuswhere = "and a.status in ('" + statuslist.Replace(",", "','") + "') "; } string formidwhere = string.Empty; if (!string.IsNullOrEmpty(formidlist) && formidlist.CompareTo("ALL") != 0) { formidwhere = "and a.form_id in ('" + formidlist.Replace(",", "','") + "') "; } string assetidwhere = string.Empty; if (!string.IsNullOrEmpty(assetidlist) && assetidlist.CompareTo("ALL") != 0) { assetidwhere = "and a.asset_id in ('" + assetidlist.Replace(",", "','") + "') "; } string assetnamewhere = string.Empty; if (!string.IsNullOrEmpty(assetname) && assetname.CompareTo("ALL") != 0) { assetnamewhere = "and a.asset_name like '%" + assetname + "%' "; } string formdatewhere = string.Empty; if (!string.IsNullOrEmpty(fromdate)) { formdatewhere = "and a.form_date >= '" + Convert.ToDateTime(fromdate) + "' "; } if (!string.IsNullOrEmpty(todate)) { formdatewhere += "and a.form_date <= '" + Convert.ToDateTime(todate) + "' "; } BindingCollection <modAssetEvaluate> modellist = new BindingCollection <modAssetEvaluate>(); //Execute a query to read the categories string sql = "select form_id,form_date,status,no,asset_id,asset_name,net_mny,evaluate_mny,remark,update_user,update_time,acc_name,acc_seq " + "from asset_evaluate a where 1=1 " + statuswhere + formidwhere + formdatewhere + assetidwhere + assetnamewhere + " order by asset_id,form_id"; using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql)) { while (rdr.Read()) { modAssetEvaluate model = new modAssetEvaluate(); model.FormId = dalUtility.ConvertToString(rdr["form_id"]); model.FormDate = dalUtility.ConvertToDateTime(rdr["form_date"]); model.Status = dalUtility.ConvertToInt(rdr["status"]); model.No = dalUtility.ConvertToString(rdr["no"]); model.AssetId = dalUtility.ConvertToString(rdr["asset_id"]); model.AssetName = dalUtility.ConvertToString(rdr["asset_name"]); model.NetMny = dalUtility.ConvertToDecimal(rdr["net_mny"]); model.EvaluateMny = dalUtility.ConvertToDecimal(rdr["evaluate_mny"]); model.Remark = dalUtility.ConvertToString(rdr["remark"]); model.UpdateUser = dalUtility.ConvertToString(rdr["update_user"]); model.UpdateTime = dalUtility.ConvertToDateTime(rdr["update_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); } }