Beispiel #1
0
        /// <summary>
        /// 检查输入是否合法
        /// </summary>
        /// <returns></returns>
        private bool checkInput()
        {
            if (this.txtEqName.Text.Trim() == "")
            {
                untCommon.InfoMsg("请输入资产名称");
                return(false);
            }
            if (this.cbxEqType.Text.Trim() == "")
            {
                untCommon.InfoMsg("请选择资产类别");
                return(false);
            }
            if (this.txtGB.Text.Trim() == "")
            {
                untCommon.InfoMsg("请输入国标码");
                return(false);
            }
            if (this.txtCount.Text.Trim() == "")
            {
                untCommon.InfoMsg("请输入资产的数量。");
                return(false);
            }
            if (this.txtPrice.Text.Trim() == "")
            {
                untCommon.InfoMsg("请输入资产的价值。");
                return(false);
            }

            if (this.txtDepartment.Text.Trim() == "")
            {
                untCommon.InfoMsg("请输入部门名称");
                return(false);
            }
            else
            {
                string depart = DepartMgr.GetIdFromName(this.txtDepartment.Text);
                if (depart == "")
                {
                    untCommon.InfoMsg("没有这个部门");
                    return(false);
                }
            }

            if (double.Parse(this.txtPrice.Text) <= 0)
            {
                untCommon.InfoMsg("价值请输入大于零的数字");
                return(false);
            }
            if (int.Parse(this.txtCount.Text) <= 0)
            {
                untCommon.InfoMsg("价值请输入大于零的数字");
                return(false);
            }


            if (this.txtUSDPrice.Text.Trim() != "" && double.Parse(this.txtUSDPrice.Text) <= 0)
            {
                untCommon.InfoMsg("美金单价请输入大于零的数字");
                return(false);
            }

            if (this.txtArea.Text.Trim() != "" && double.Parse(this.txtArea.Text) <= 0)
            {
                untCommon.InfoMsg("土地/建筑面积请输入大于零的数字");
                return(false);
            }
            if (this.txtTenuArea.Text.Trim() != "" && double.Parse(this.txtTenuArea.Text) <= 0)
            {
                untCommon.InfoMsg("自用面积请输入大于零的数字");
                return(false);
            }
            if (this.txtTenuPrice.Text.Trim() != "" && double.Parse(this.txtTenuPrice.Text) <= 0)
            {
                untCommon.InfoMsg("自用价值请输入大于零的数字");
                return(false);
            }
            if (this.txtCertLim.Text.Trim() != "" && double.Parse(this.txtCertLim.Text) <= 0)
            {
                untCommon.InfoMsg("权属年限请输入大于零的数字");
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        //保存修改的信息
        private void toolEqUpdate_Click(object sender, EventArgs e)
        {
            if (this.checkInput())
            {
                Equipment eq = new Equipment();
                eq.EqNo       = this.txtEqNo.Text;
                eq.EqName     = this.txtEqName.Text;
                eq.AssetNo    = this.txtAssetNo.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      = "";
                eq.Remark     = this.txtRemark.Text;

                eq.Photo = this.getPhotoPath();


                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;
                }

                //判断更新模式
                switch (this.mode)
                {
                case 0:
                    this.DialogResult = DialogResult.OK;
                    break;

                //直接修改
                case 1:
                {
                    int error = 0;
                    //0级和1级用户直接更新
                    if (_power == "0" || _power == "1")
                    {
                        foreach (string field in eqnoList)
                        {
                            eq.EqNo  = field;
                            eq.State = "入库";
                            if (EqMgr.Update(eq))
                            {
                                //
                            }
                            else
                            {
                                error++;
                            }
                        }
                        if (error == 0)
                        {
                            untCommon.InfoMsg("更新成功");
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }
                        else
                        {
                            untCommon.InfoMsg("操作失败,失败数目为:" + error.ToString());
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }
                    }
                    else
                    {
                        DataTable Empdt = EmployeeMgr.GetAllName();
                        foreach (string field in eqnoList)
                        {
                            eq.EqNo  = "U" + this.Loginid + DateTime.Now.ToString("yyyyMMddHHmmss") + field;
                            eq.State = "更新待审核";
                            if (EqMgr.Add(eq))
                            {
                                //
                            }
                            else
                            {
                                error++;
                            }
                        }
                        if (error == 0)
                        {
                            untCommon.InfoMsg("更新成功,请等待审核");
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }
                        else
                        {
                            untCommon.InfoMsg("操作失败,失败数目为:" + error.ToString());
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }
                    }

                    break;
                }


                //直接批量修改
                case 2:
                {
                    string question = "确定要更改这单数量为: ";
                    question += EqMgr.AssetCount(this.asset).ToString() + " 的资产吗?";
                    if (untCommon.QuestionMsg(question))
                    {
                        if (_power == "0" || _power == "1")
                        {
                            eq.State = "入库";

                            if (EqMgr.UpdateByAsset(eq, asset))
                            {
                                untCommon.InfoMsg("更新成功");
                                this.DialogResult = DialogResult.OK;
                                this.Close();
                            }
                            else
                            {
                                untCommon.InfoMsg("更新失败。");
                                this.DialogResult = DialogResult.OK;
                                this.Close();
                            }
                        }
                        else
                        {
                            List <string> list  = EqMgr.GetEqNoByAssetNo(this.asset);
                            DataTable     Empdt = EmployeeMgr.GetAllName();
                            int           error = 0;
                            if (list != null)
                            {
                                foreach (string field in list)
                                {
                                    eq.EqNo  = "U" + this.name2ID(Empdt, this._user, "name") + DateTime.Now.ToString("yyyyMMddHHmmss") + field;
                                    eq.State = "更新待审核";
                                    if (EqMgr.Add(eq))
                                    {
                                    }
                                    else
                                    {
                                        error++;
                                    }
                                }
                            }
                            if (error == 0)
                            {
                                untCommon.InfoMsg("更新信息提交成功,请等待审核");
                                this.DialogResult = DialogResult.OK;
                                this.Close();
                            }
                            else
                            {
                                untCommon.InfoMsg("更新信息发生错误\n" + "失败数为: " + error.ToString());
                                this.DialogResult = DialogResult.OK;
                                this.Close();
                            }
                        }
                    }


                    break;
                }

                //从新增审核处修改
                case 3:
                {
                    eq.State = "新增待审核";
                    if (EqMgr.UpdateByAsset(eq, asset))
                    {
                        untCommon.InfoMsg("更新信息提交成功,请等待审核");
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        untCommon.InfoMsg("更新失败。");
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    break;
                }

                //从更新审核处修改
                case 4:
                {
                    int       error = 0;
                    DataTable Empdt = EmployeeMgr.GetAllName();
                    foreach (string field in eqnoList)
                    {
                        eq.EqNo  = field;
                        eq.State = "更新待审核";
                        if (EqMgr.Update(eq))
                        {
                            //
                        }
                        else
                        {
                            error++;
                        }
                    }

                    if (error == 0)
                    {
                        untCommon.InfoMsg("更新成功,请等待审核");
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        untCommon.InfoMsg("操作失败,失败数目为:" + error.ToString());
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    break;
                }
                }
            }
        }
Beispiel #3
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();
                }
            }
        }