Exemplo n.º 1
0
 private void toolEdit_Click(object sender, EventArgs e)
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         if (DBGrid.CurrentRow == null)
         {
             return;
         }
         modAssetList  mod = (modAssetList)DBGrid.CurrentRow.DataBoundItem;
         EditAssetList frm = new EditAssetList();
         frm.EditItem(mod.AssetId);
         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;
     }
 }
Exemplo n.º 2
0
 private void mnuAssetEvaluate_Click(object sender, EventArgs e)
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         if (DBGrid.CurrentRow == null)
         {
             return;
         }
         modAssetList     mod = (modAssetList)DBGrid.CurrentRow.DataBoundItem;
         dalAssetEvaluate dal = new dalAssetEvaluate();
         BindingCollection <modAssetEvaluate> list = dal.GetIList(string.Empty, string.Empty, mod.AssetId, string.Empty, string.Empty, string.Empty, out Util.emsg);
         if (list != null && list.Count > 0)
         {
             frmViewList frm = new frmViewList();
             frm.InitViewList(clsTranslate.TranslateString("Asset Evaluate"), list);
             frm.ShowDialog();
         }
         else
         {
             MessageBox.Show(clsTranslate.TranslateString("No data found!"), 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;
     }
 }
Exemplo n.º 3
0
 public void EditItem(string assetid)
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         _action     = "EDIT";
         modAssetList mod = _dal.GetItem(assetid, out Util.emsg);
         if (mod != null)
         {
             txtAssetId.Text              = mod.AssetId;
             txtAssetName.Text            = mod.AssetName;
             txtAssetProperty.Text        = mod.AssetProperty;
             dtpSignDate.Value            = mod.SignDate;
             dtpPurchaseDate.Value        = mod.PurchaseDate;
             txtControlDepart.Text        = mod.ControlDepart;
             txtUsingDepart.Text          = mod.UsingDepart;
             cboDepreMethod.SelectedValue = mod.DepreMethod;
             txtRawMny.Text    = mod.RawMny.ToString();
             txtLastMny.Text   = mod.LastMny.ToString();
             txtRawQty.Text    = mod.RawQty.ToString();
             txtDepreUnit.Text = mod.DepreUnit;
             txtRemark.Text    = mod.Remark;
             if (mod.Status == 2)
             {
                 status4.Image = Properties.Resources.audited;
                 Util.ChangeStatus(this, true);
                 toolSave.Enabled = false;
             }
             else
             {
                 status4.Image = null;
                 Util.ChangeStatus(this, false);
                 toolSave.Enabled = true;
             }
         }
         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;
     }
 }
Exemplo n.º 4
0
 private void btnAssetId_Click(object sender, EventArgs e)
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         dalAssetList dal = new dalAssetList();
         BindingCollection <modAssetList> list = dal.GetIList("1", string.Empty, string.Empty, string.Empty, out Util.emsg);
         if (list != null && list.Count > 0)
         {
             frmViewList frm = new frmViewList();
             frm.InitViewList("请选择资产:", list);
             frm.Selection = true;
             if (frm.ShowDialog() == DialogResult.OK)
             {
                 modAssetList mod = dal.GetItem(Util.retValue1, out Util.emsg);
                 if (mod != null)
                 {
                     txtAssetId.Text   = mod.AssetId;
                     txtAssetName.Text = mod.AssetName;
                     txtNetMny.Text    = mod.NetMny.ToString();
                 }
                 else
                 {
                     MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
         }
         else
         {
             if (!string.IsNullOrEmpty(Util.emsg))
             {
                 MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 MessageBox.Show(clsTranslate.TranslateString("No data found!"), 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;
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// get table record
 /// <summary>
 /// <param name=assetid>assetid</param>
 /// <param name=out emsg>return error message</param>
 ///<returns>get a record detail of assetlist</returns>
 public modAssetList GetItem(string assetid, out string emsg)
 {
     try
     {
         //Execute a query to read the categories
         string sql = string.Format("select asset_id,asset_name,asset_property,status,sign_date,purchase_date,control_depart,using_depart,depre_method,raw_qty,raw_mny,last_mny,depre_unit,remark,update_user,update_time,acc_name,acc_seq from asset_list where asset_id='{0}' order by asset_id", assetid);
         using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
         {
             if (rdr.Read())
             {
                 modAssetList model = new modAssetList();
                 model.AssetId       = dalUtility.ConvertToString(rdr["asset_id"]);
                 model.AssetName     = dalUtility.ConvertToString(rdr["asset_name"]);
                 model.AssetProperty = dalUtility.ConvertToString(rdr["asset_property"]);
                 model.Status        = dalUtility.ConvertToInt(rdr["status"]);
                 model.SignDate      = dalUtility.ConvertToDateTime(rdr["sign_date"]);
                 model.PurchaseDate  = dalUtility.ConvertToDateTime(rdr["purchase_date"]);
                 model.ControlDepart = dalUtility.ConvertToString(rdr["control_depart"]);
                 model.UsingDepart   = dalUtility.ConvertToString(rdr["using_depart"]);
                 model.DepreMethod   = dalUtility.ConvertToString(rdr["depre_method"]);
                 model.RawQty        = dalUtility.ConvertToDecimal(rdr["raw_qty"]);
                 model.RawMny        = dalUtility.ConvertToDecimal(rdr["raw_mny"]);
                 model.LastMny       = dalUtility.ConvertToDecimal(rdr["last_mny"]);
                 model.DepreMny      = GetDepreMny(model.AssetId, string.Empty);
                 model.EvaluateLost  = GetEvaluateLost(model.AssetId, string.Empty);
                 model.NetMny        = model.RawMny - model.DepreMny - model.EvaluateLost;
                 model.DepreUnit     = dalUtility.ConvertToString(rdr["depre_unit"]);
                 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);
     }
 }
Exemplo n.º 6
0
        private void DBGrid_SelectionChanged(object sender, EventArgs e)
        {
            if (DBGrid.CurrentRow == null)
            {
                return;
            }

            modAssetList mod = (modAssetList)DBGrid.CurrentRow.DataBoundItem;

            if (mod.DepreMethod == "工作量法")
            {
                mnuWorkQty.Enabled = true;
            }
            else
            {
                mnuWorkQty.Enabled = false;
            }
        }
Exemplo n.º 7
0
        public void InitData(modAssetList mod)
        {
            modAssetWorkQty modw = _dal.GetItem(mod.AssetId, Util.modperiod.AccName, out Util.emsg);

            if (modw != null)
            {
                txtAssetId.Text   = modw.AssetId;
                txtAssetName.Text = modw.AssetName;
                txtQty.Text       = modw.WorkQty.ToString();
                txtRemark.Text    = modw.Remark;
                _action           = "EDIT";
            }
            else
            {
                txtAssetId.Text   = mod.AssetId;
                txtAssetName.Text = mod.AssetName;
                _action           = "NEW";
            }
            Status1.Text = _action;
            //Status2.Text = "工量余存:" + mod.LeftQty;
        }
Exemplo n.º 8
0
 /// <summary>
 /// update a assetlist
 /// <summary>
 /// <param name=assetid>assetid</param>
 /// <param name=mod>model object of assetlist</param>
 /// <param name=out emsg>return error message</param>
 /// <returns>true/false</returns>
 public bool Update(string assetid, modAssetList mod, out string emsg)
 {
     try
     {
         string sql = string.Format("update asset_list set asset_name='{0}',asset_property='{1}',status='{2}',sign_date='{3}',purchase_date='{4}',control_depart='{5}',using_depart='{6}',depre_method='{7}',raw_qty={8},raw_mny={9},last_mny={10},depre_unit='{11}',remark='{12}' where asset_id='{13}'", mod.AssetName, mod.AssetProperty, 1, mod.SignDate, mod.PurchaseDate, mod.ControlDepart, mod.UsingDepart, mod.DepreMethod, mod.RawQty, mod.RawMny, mod.LastMny, mod.DepreUnit, mod.Remark, assetid);
         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);
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// insert a assetlist
 /// <summary>
 /// <param name=mod>model object of assetlist</param>
 /// <param name=out emsg>return error message</param>
 /// <returns>true/false</returns>
 public bool Insert(modAssetList mod, out string emsg)
 {
     try
     {
         string sql = string.Format("insert into asset_list(asset_id,asset_name,asset_property,status,sign_date,purchase_date,control_depart,using_depart,depre_method,raw_qty,last_mny,depre_unit,remark,update_user,update_time)values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}',{9},{10},'{11}','{12}','{13}',getdate())", mod.AssetId, mod.AssetName, mod.AssetProperty, mod.Status, mod.SignDate, mod.PurchaseDate, mod.ControlDepart, mod.UsingDepart, mod.DepreMethod, mod.RawQty, mod.RawMny, mod.LastMny, mod.DepreUnit, 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);
     }
 }
Exemplo n.º 10
0
 private void mnuWorkQty_Click(object sender, EventArgs e)
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         if (DBGrid.CurrentRow == null)
         {
             return;
         }
         modAssetList mod = (modAssetList)DBGrid.CurrentRow.DataBoundItem;
         EditWorkQty  frm = new EditWorkQty();
         frm.InitData(mod);
         frm.ShowDialog();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// get all assetlist
        /// <summary>
        /// <param name=statuslist>statuslist</param>
        /// <param name=assetidlist>assetidlist</param>
        /// <param name=assetname>assetname</param>
        /// <param name=out emsg>return error message</param>
        ///<returns>details of all assetlist</returns>
        public BindingCollection <modAssetList> GetIList(string statuslist, string assetidlist, string assetname, string endaccname, out string emsg)
        {
            try
            {
                BindingCollection <modAssetList> modellist = new BindingCollection <modAssetList>();
                //Execute a query to read the categories
                string statuswhere = string.Empty;
                if (!string.IsNullOrEmpty(statuslist) && statuslist.CompareTo("ALL") != 0)
                {
                    statuswhere = "and status in ('" + statuslist.Replace(",", "','") + "') ";
                }

                string assetidwhere = string.Empty;
                if (!string.IsNullOrEmpty(assetidlist) && assetidlist.CompareTo("ALL") != 0)
                {
                    assetidwhere = "and asset_id in ('" + assetidlist.Replace(",", "','") + "') ";
                }

                string assetnamewhere = string.Empty;
                if (!string.IsNullOrEmpty(assetname) && assetname.CompareTo("ALL") != 0)
                {
                    assetnamewhere = "and asset_name like '%" + assetname + "%' ";
                }

                string sql = "select asset_id,asset_name,asset_property,status,sign_date,purchase_date,control_depart,using_depart,depre_method,raw_qty,raw_mny,last_mny,depre_unit,remark,update_user,update_time,acc_name,acc_seq "
                             + "from asset_list where 1=1 " + statuswhere + assetidwhere + assetnamewhere + " order by asset_id";
                using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
                {
                    while (rdr.Read())
                    {
                        modAssetList model = new modAssetList();
                        model.AssetId       = dalUtility.ConvertToString(rdr["asset_id"]);
                        model.AssetName     = dalUtility.ConvertToString(rdr["asset_name"]);
                        model.AssetProperty = dalUtility.ConvertToString(rdr["asset_property"]);
                        model.Status        = dalUtility.ConvertToInt(rdr["status"]);
                        model.SignDate      = dalUtility.ConvertToDateTime(rdr["sign_date"]);
                        model.PurchaseDate  = dalUtility.ConvertToDateTime(rdr["purchase_date"]);
                        model.ControlDepart = dalUtility.ConvertToString(rdr["control_depart"]);
                        model.UsingDepart   = dalUtility.ConvertToString(rdr["using_depart"]);
                        model.DepreMethod   = dalUtility.ConvertToString(rdr["depre_method"]);
                        model.RawQty        = dalUtility.ConvertToDecimal(rdr["raw_qty"]);
                        model.RawMny        = dalUtility.ConvertToDecimal(rdr["raw_mny"]);
                        model.LastMny       = dalUtility.ConvertToDecimal(rdr["last_mny"]);
                        model.DepreMny      = GetDepreMny(model.AssetId, endaccname);
                        model.EvaluateLost  = GetEvaluateLost(model.AssetId, endaccname);
                        model.NetMny        = model.RawMny - model.DepreMny - model.EvaluateLost;
                        model.DepreUnit     = dalUtility.ConvertToString(rdr["depre_unit"]);
                        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);
            }
        }
Exemplo n.º 12
0
        private void toolSave_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                if (dtpSignDate.Value < Util.modperiod.StartDate)
                {
                    MessageBox.Show("该日期的数据已锁定,不能更新数据!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dtpSignDate.Focus();
                    return;
                }
                if (cboDepreMethod.SelectedValue == null || string.IsNullOrEmpty(cboDepreMethod.SelectedValue.ToString()))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Depre Method") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    cboDepreMethod.Focus();
                    return;
                }

                if (string.IsNullOrEmpty(txtRawMny.Text.Trim()))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Start Mny") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtRawMny.Focus();
                    return;
                }
                else if (!Util.IsNumeric(txtRawMny.Text))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Start Mny") + clsTranslate.TranslateString(" must be a numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtRawMny.Focus();
                    return;
                }
                else if (Convert.ToDecimal(txtRawMny.Text.Trim()) <= 0)
                {
                    MessageBox.Show(clsTranslate.TranslateString("Start Mny") + clsTranslate.TranslateString(" must > 0!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtRawMny.Focus();
                    return;
                }

                if (string.IsNullOrEmpty(txtLastMny.Text.Trim()))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Last Mny") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtLastMny.Focus();
                    return;
                }
                else if (!Util.IsNumeric(txtLastMny.Text))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Last Mny") + clsTranslate.TranslateString(" must be a numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtLastMny.Focus();
                    return;
                }
                else if (Convert.ToDecimal(txtLastMny.Text.Trim()) < 0)
                {
                    MessageBox.Show(clsTranslate.TranslateString("Last Mny") + clsTranslate.TranslateString(" must >= 0!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtLastMny.Focus();
                    return;
                }

                if (string.IsNullOrEmpty(txtRawQty.Text.Trim()))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Raw Qty") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtRawQty.Focus();
                    return;
                }
                else if (!Util.IsNumeric(txtRawQty.Text))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Raw Qty") + clsTranslate.TranslateString(" must be a numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtRawQty.Focus();
                    return;
                }
                else if (Convert.ToDecimal(txtRawQty.Text.Trim()) <= 0)
                {
                    MessageBox.Show(clsTranslate.TranslateString("Raw Qty") + clsTranslate.TranslateString(" must > 0!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtRawQty.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 (string.IsNullOrEmpty(txtDepreUnit.Text))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Depre Unit") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtDepreUnit.Focus();
                    return;
                }
                if (cboDepreMethod.SelectedValue == null)
                {
                    MessageBox.Show(clsTranslate.TranslateString("Depre Method") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    cboDepreMethod.Focus();
                    return;
                }

                modAssetList mod = new modAssetList();
                mod.AssetId       = txtAssetId.Text.Trim();
                mod.AssetName     = txtAssetName.Text.Trim();
                mod.AssetProperty = txtAssetProperty.Text.Trim();
                mod.ControlDepart = txtControlDepart.Text.Trim();
                mod.UsingDepart   = txtUsingDepart.Text.Trim();
                mod.SignDate      = dtpSignDate.Value;
                mod.PurchaseDate  = dtpPurchaseDate.Value;
                mod.DepreMethod   = cboDepreMethod.SelectedValue.ToString();
                mod.DepreUnit     = txtDepreUnit.Text.Trim();
                mod.RawMny        = Convert.ToDecimal(txtRawMny.Text);
                mod.LastMny       = Convert.ToDecimal(txtLastMny.Text);
                mod.RawQty        = Convert.ToDecimal(txtRawQty.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.AssetId, 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;
            }
        }