示例#1
0
        private void frmEqAdd_Load(object sender, EventArgs e)
        {
            initcbx(this.cbxFunds, "Funds");
            initcbx(this.cbxPriceType, "PriceType");
            initcbx(this.cbxUsage, "Usage");
            initcbx(this.cbxDirection, "Direction");
            initcbx(this.cbxBuyWay, "BuyWay");
            initcbx(this.cbxGetWay, "GetWay");
            initcbx(this.cbxCarUse, "CarUse");
            initcbx(this.cbxCarBP, "CarBP");
            initcbx(this.cbxFormation, "Formation");
            initcbx(this.cbxPR, "Pr");
            initcbx(this.cbxCertNature, "CertNature");
            initcbx(this.cbxStructure, "Structure");
            initcbx(this.cbxUnit, "Unit");
            initcbx(this.cbxKeepPlace, "KeepPlace");
            initcbx(this.cbxRelicLv, "RelicLv");
            initcbx(this.cbxCampus, "Campus");

            this.txtDepartment.Text = SysUserMgr.GetDepartmentIDByUser(this._user);
            this.txtDepartment.Text = DepartMgr.GetNameFromId(this.txtDepartment.Text);
            this.dtpAddDate.Text    = DateTime.Now.ToShortDateString();
            this.txtAgent.Text      = this._user;
            //cbxEqKeeper的初始化与其他不同,其ValueMember和DisplayMember是不一样的
            initcbxEmployee(this.cbxEqKeeper);
            initcbxEmployee(this.cbxPurchaser);
        }
示例#2
0
        /// <summary>
        /// 添加资产
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolEqAdd_Click(object sender, EventArgs e)
        {
            if (this.checkInput())
            {
                this.SetNo();        //生成随机编号
                int       error = 0; //错误标志
                Equipment eq    = new Equipment();
                eq.EqName     = this.txtEqName.Text;
                eq.EduNo      = this.txtEduNo.Text;
                eq.EqType     = this.cbxEqType.Text;
                eq.Gb         = this.txtGB.Text;
                eq.Usage      = this.cbxUsage.Text;
                eq.Unit       = this.cbxUnit.Text;
                eq.Direction  = this.cbxDirection.Text;
                eq.BuyWay     = this.cbxBuyWay.Text;
                eq.GetWay     = this.cbxGetWay.Text;
                eq.Purchaser  = this.cbxPurchaser.Text;
                eq.Agent      = this.txtAgent.Text;
                eq.Brand      = this.txtBrand.Text;
                eq.Model      = this.txtModel.Text;
                eq.Country    = this.txtCountry.Text;
                eq.Mfrs       = this.txtMfrs.Text;
                eq.ProductNo  = this.txtProductNo.Text;
                eq.Supplier   = this.txtSupplier.Text;
                eq.PriceType  = this.cbxPriceType.Text;
                eq.EqKeeper   = this.cbxEqKeeper.Text;
                eq.Department = DepartMgr.GetIdFromName(this.txtDepartment.Text);
                eq.Campus     = this.cbxCampus.Text;
                eq.KeepPlace  = this.cbxKeepPlace.Text;
                eq.Cn         = this.txtCN.Text;
                eq.InvNo      = this.txtInvNo.Text;
                eq.Funds      = this.cbxFunds.Text;
                eq.BelongTo   = "";
                eq.Photo      = this.photoPath;
                eq.Remark     = this.txtRemark.Text;

                if (this.dtpGetDate.Checked == true)
                {
                    eq.GetDate = this.dtpGetDate.Value.ToShortDateString();
                }
                else
                {
                    eq.GetDate = "";
                }

                if (dtpAddDate.Checked == true)
                {
                    eq.AddDate = this.dtpAddDate.Value.ToShortDateString();
                }
                else
                {
                    eq.AddDate = "";
                }

                if (this.dtpBirthday.Checked == true)
                {
                    eq.Birthday = this.dtpBirthday.Value.ToShortDateString();
                }
                else
                {
                    eq.Birthday = "";
                }

                if (this.dtpSvcDate.Checked == true)
                {
                    eq.SvcDate = this.dtpSvcDate.Value.ToShortDateString();
                }
                else
                {
                    eq.SvcDate = "";
                }
                /*****************************根据资产类别判断所要填的项********************************************/
                //资产类别为“土地、房屋及构筑物”时
                if (eq.EqType == "土地、房屋及构筑物")
                {
                    eq.Pr         = this.cbxPR.Text;
                    eq.Address    = this.txtAddress.Text;
                    eq.CertNature = this.cbxCertNature.Text;
                    eq.Structure  = this.cbxStructure.Text;

                    //有产权时以下四项才可以被填写
                    if (eq.Pr == "有产权")
                    {
                        if (this.txtCertNo.Text.Trim() == "")
                        {
                            untCommon.InfoMsg("请输入权属证号");
                            return;
                        }
                        else
                        {
                            eq.CertNo = this.txtCertNo.Text;
                        }

                        if (this.dtpIssueDate.Checked == false)
                        {
                            untCommon.InfoMsg("请选择发证日期");
                            return;
                        }
                        else
                        {
                            eq.IssueDate = this.dtpIssueDate.Value.ToShortDateString();
                        }

                        if (this.txtCertProve.Text.Trim() == "")
                        {
                            untCommon.InfoMsg("请输入权属证明");
                            return;
                        }
                        else
                        {
                            eq.CertProve = this.txtCertProve.Text;
                        }

                        try
                        {
                            eq.CertLim = int.Parse(this.txtCertLim.Text);
                        }
                        catch (FormatException)
                        {
                            untCommon.ErrorMsg("权属年限请输入数字。");
                            return;
                        }
                    }
                    else
                    {
                        eq.CertNo    = "";
                        eq.IssueDate = "";
                        eq.CertProve = "";
                        eq.CertLim   = 0;
                    }
                    try
                    {
                        eq.Area = double.Parse(this.txtArea.Text);
                    }
                    catch (FormatException)
                    {
                        untCommon.ErrorMsg("建筑/土地面积请输入数字。");
                        return;
                    }

                    try
                    {
                        eq.TenuArea = double.Parse(this.txtTenuArea.Text);
                    }
                    catch (FormatException)
                    {
                        untCommon.ErrorMsg("自用面积请输入数字。");
                        return;
                    }

                    try
                    {
                        eq.TenuPrice = double.Parse(this.txtTenuPrice.Text);
                    }
                    catch (FormatException)
                    {
                        untCommon.ErrorMsg("自用价值请输入数字。");
                        return;
                    }
                }
                else
                {
                    eq.Pr         = "";
                    eq.CertNo     = "";
                    eq.IssueDate  = "";
                    eq.CertProve  = "";
                    eq.Address    = "";
                    eq.CertNature = "";
                    eq.Structure  = "";
                    eq.Area       = 0;
                    eq.TenuArea   = 0;
                    eq.TenuPrice  = 0;
                    eq.CertLim    = 0;
                }

                //资产类别为"通用设备(车辆)"
                if (eq.EqType == "通用设备(车辆)")
                {
                    eq.CarUse    = this.cbxCarUse.Text;
                    eq.CarBP     = this.cbxCarBP.Text;
                    eq.LicNo     = this.txtLicNo.Text;
                    eq.Dspl      = this.txtDSPL.Text;
                    eq.EngNo     = this.txtEngNo.Text;
                    eq.Formation = this.cbxFormation.Text;
                }
                else
                {
                    eq.CarUse    = "";
                    eq.CarBP     = "";
                    eq.LicNo     = "";
                    eq.Dspl      = "";
                    eq.EngNo     = "";
                    eq.Formation = "";
                }

                //资产类别为"无形资产"
                if (eq.EqType == "无形资产")
                {
                    eq.RegAuz    = this.txtRegAuz.Text;
                    eq.PatNo     = this.txtPatNo.Text;
                    eq.ApvNo     = this.txtApvNo.Text;
                    eq.MgtAgency = this.txtMgtAgency.Text;

                    if (this.dtpRegTime.Checked == true)
                    {
                        eq.RegTime = this.dtpRegTime.Value.ToShortDateString();
                    }
                    else
                    {
                        eq.RegTime = "";
                    }
                }
                else
                {
                    eq.RegAuz    = "";
                    eq.RegTime   = "";
                    eq.PatNo     = "";
                    eq.ApvNo     = "";
                    eq.MgtAgency = "";
                }
                //资产类别为"文物和陈列品"
                if (eq.EqType == "文物和陈列品")
                {
                    eq.RelicLv = this.cbxRelicLv.Text;
                }
                else
                {
                    eq.RelicLv = "";
                }


                /*************************************判断结束******************************************************/
                try
                {
                    count = int.Parse(this.txtCount.Text);
                }
                catch (FormatException)
                {
                    untCommon.ErrorMsg("数量请输入数字。");
                    return;
                }
                try
                {
                    eq.Price = double.Parse(this.txtPrice.Text);
                }
                catch (FormatException)
                {
                    untCommon.ErrorMsg("价值请输入数字。");
                    return;
                }

                try
                {
                    if (this.txtUSDPrice.Text.Trim() != "")
                    {
                        eq.UsdPrice = double.Parse(this.txtUSDPrice.Text);
                    }
                    else
                    {
                        eq.UsdPrice = 0;
                    }
                }
                catch (FormatException)
                {
                    untCommon.ErrorMsg("美金单价请输入数字。");
                    return;
                }

                if (_power == "0" || _power == "1")
                {
                    int tempCount  = EqMgr.getTempAssetCount();
                    int allCount   = EqMgr.getAllAssetCount();
                    int eqCount    = EqMgr.getAllEqCount();
                    int assetCount = allCount - tempCount + 1;
                    eq.State = "入库";
                    for (int j = 1; j <= count; j++)
                    {
                        eq.EqNo    = DateTime.Now.Year.ToString() + string.Format("{0:D6}", eqCount + j);
                        eq.AssetNo = SysUserMgr.GetDepartmentIDByUser(this._user) + DateTime.Now.Year.ToString() + string.Format("{0:D4}", assetCount);
                        if (EqMgr.Add(eq))
                        {
                            /*if (!SqlFileMgr.PhotoAdd(eq.EqNo, photoPath))
                             *  error++;
                             * if (!WriteAttachment(eq.EqNo))
                             *  error++;*/
                        }
                        else
                        {
                            error++;
                        }
                    }
                }
                else
                {
                    for (int i = 1; i <= count; i++)
                    {
                        eq.EqNo    = "TE" + random + string.Format("{0:000}", i);
                        eq.AssetNo = "TA" + random + string.Format("{0:000}", count);
                        eq.State   = "新增待审核";
                        //if (this.pbPhoto.Image != null)
                        //photoPath = this.pbPhoto.ImageLocation;
                        if (EqMgr.Add(eq))
                        {
                            /*if (!SqlFileMgr.PhotoAdd(eq.EqNo, photoPath))
                             *  error++;
                             * if (!WriteAttachment(eq.EqNo))
                             *  error++;*/
                        }
                        else
                        {
                            error++;
                        }
                    }
                }

                if (error == 0)
                {
                    untCommon.InfoMsg("添加成功");
                    ClearInput();
                    this.SetNo();
                    this.Close();
                }
                else
                {
                    untCommon.InfoMsg("错误数目:" + error.ToString());
                    this.SetNo();
                }
            }
        }