zclr.aspx.cs
上传用户:lishan0805
上传日期:2019-12-08
资源大小:12048k
文件大小:7k
源码类别:

OA系统

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using COM.OA.Entity;
  12. using COM.OA.BLL;
  13. using System.Collections.Generic;
  14. public partial class zclr : System.Web.UI.Page
  15. {
  16.     protected void Page_Load(object sender, EventArgs e)
  17.     {
  18.          
  19.              
  20.             //取登陆人信息 
  21.             COM.OA.Entity.users loginuser = Session["loginuser"] as COM.OA.Entity.users;
  22.             //如果取不到跳转到登陆页
  23.             if (loginuser == null)
  24.             {
  25.                 this.Response.Write(string.Format(GetRedirect.ALLREDIRECT, "../login.aspx"));
  26.             }
  27.             else
  28.             {
  29.                 //登录时插数据库 编号+1
  30.                 IList<assetmanage> l = assetmanageBLL.Select();
  31.                 //没有数据
  32.                 if (l.Count == 0)
  33.                 {
  34.                     this.txtNumber.Text = "10001";
  35.                 }
  36.                 else
  37.                 {
  38.                     List<assetmanage> list = (List<assetmanage>)l;
  39.                     assetmanage ass = new assetmanage();
  40.                     ass = list[0];
  41.                     int num = Int32.Parse(ass.am_number) + 1;
  42.                     this.txtNumber.Text = num.ToString();
  43.                 }
  44.                 int Loginid = 0;
  45.                 string Loginname = "";
  46.                 Loginid = loginuser.u_em_id;
  47.                 string where = "em_id=" + Loginid;
  48.                 IList<employee> il = employeeBLL.Select(where);
  49.                 List<employee> ll = (List<employee>)il;
  50.                 employee em = new employee();
  51.                 em = ll[0];
  52.                 Loginname = em.em_name;
  53.                 Loginid = loginuser.u_id;
  54.                 this.txtBookerid.Text = Loginname;
  55.                 this.txtLoginid.Text = Loginid.ToString();
  56.             }
  57.     }
  58.     protected void btnSubmit_Click(object sender, EventArgs e)
  59.     {
  60.         string Assetname = this.txtAssetname.Text;//资产名称
  61.         string Number = this.txtNumber.Text;//编号
  62.         string Measureunit = this.txtMeasureunit.Text;//计量单位
  63.         string s = this.txtScalar.Text; //数量
  64.         int Scalar;
  65.         if (s.Equals(""))
  66.         {
  67.             Scalar = 0;
  68.         }
  69.         else
  70.         {
  71.             Scalar = Int32.Parse(this.txtScalar.Text);
  72.         }
  73.         string Spectype = this.txtSpectype.Text;//规格型号
  74.         string LeaveFactoryNumber = this.txtLeaveFactoryNumber.Text;//出厂编号
  75.         string ArtletterNumber = this.txtArtletterNumber.Text;//技术证书号
  76.         string b = this.txtBuyPrice.Text;//购买价格
  77.         float BuyPrice;
  78.         if (b.Equals(""))
  79.         {
  80.             BuyPrice = 0;
  81.         }
  82.         else
  83.         {
  84.             BuyPrice = float.Parse(this.txtBuyPrice.Text);
  85.         }
  86.         string i = this.txtInstallcost.Text;//安装费
  87.         float Installcost;
  88.         if (i.Equals(""))
  89.         {
  90.             Installcost = 0;
  91.         }
  92.         else
  93.         {
  94.             Installcost = float.Parse(this.txtInstallcost.Text);
  95.         }
  96.         string d = this.txtDepreciationcost.Text;//折旧
  97.         float Depreciationcost;
  98.         if (d.Equals(""))
  99.         {
  100.             Depreciationcost = 0;
  101.         }
  102.         else
  103.         {
  104.             Depreciationcost = float.Parse(this.txtDepreciationcost.Text);
  105.         }
  106.         string bv = this.txtBetvalue.Text;//净值
  107.         float Betvalue;
  108.         if (bv.Equals(""))
  109.         {
  110.             Betvalue = 0;
  111.         }
  112.         else
  113.         {
  114.             Betvalue = float.Parse(this.txtBetvalue.Text);
  115.         }
  116.         string Production = this.txtProduction.Text;//生产单位
  117.         string Productiondate = this.wdProductiondate.Text;//生产年月
  118.         DateTime pdate;
  119.         if (Production.Equals(""))
  120.         {
  121.             pdate = DateTime.Parse("1753-1-1");
  122.         }
  123.         else
  124.         {
  125.             pdate = DateTime.Parse(this.wdProductiondate.Text);
  126.         }
  127.         string Deliverusetime = this.wdDeliverusetime.Text;//交付使用日期
  128.         DateTime dtime;
  129.         if (Deliverusetime.Equals(""))
  130.         {
  131.             dtime = DateTime.Parse("1753-1-1");
  132.         }
  133.         else
  134.         {
  135.             dtime = DateTime.Parse(this.wdDeliverusetime.Text);
  136.         }
  137.         string a = this.txtAdvanceuseyear.Text;//预计使用年限
  138.         int Advanceuseyear;
  139.         if (a.Equals(""))
  140.         {
  141.             Advanceuseyear = 0;
  142.         }
  143.         else
  144.         {
  145.             Advanceuseyear = Int32.Parse(this.txtAdvanceuseyear.Text);
  146.         }
  147.         string Buyordept = this.txtBuyordept.Text;//请购人或部门
  148.         string Storageordept = this.txtStorageordept.Text;//保管人或部门
  149.         string Purpose = this.txtPurpose.Text;//用途
  150.         int Dept = Int32.Parse(this.ddDept.Text);//使用部门
  151.         string Useaddress = this.txtUseaddress.Text;//使用地点
  152.         string u = this.txtUsestate.Text;//使用状态
  153.         int usestate = 0;
  154.         if (u.Equals("使用中"))
  155.         {
  156.             usestate = 1;
  157.         }
  158.         int Bookerid = Int32.Parse(this.txtLoginid.Text);//录入人
  159.         string Remark = this.txtRemark.Text;//备注
  160.         DateTime Registertime = DateTime.Now;//录入时间       
  161.         assetmanage am = new assetmanage();
  162.         am.am_assetname = Assetname;
  163.         am.am_number = Number;
  164.         am.am_measureunit = Measureunit;
  165.         am.am_scalar = Scalar;
  166.         am.am_spectype = Spectype;
  167.         am.am_leavefactorynumber = LeaveFactoryNumber;
  168.         am.am_artletternumber = ArtletterNumber;
  169.         am.am_buyprice = BuyPrice;
  170.         am.am_installcost = Installcost;
  171.         am.am_depreciationcost = Depreciationcost;
  172.         am.am_betvalue = Betvalue;
  173.         am.am_production = Production;
  174.         am.am_productiondate = pdate;
  175.         am.am_deliverusetime = dtime;
  176.         am.am_advanceuseyear = Advanceuseyear;
  177.         am.am_buyordept = Buyordept;
  178.         am.am_storageordept = Storageordept;
  179.         am.am_purpose = Purpose;
  180.         am.am_dept_id = Dept;
  181.         am.am_useaddress = Useaddress;
  182.         am.am_usestate = usestate;
  183.         am.am_bookerid = Bookerid;
  184.         am.am_registertime = Registertime;
  185.         am.am_remark = Remark;
  186.         am.am_isscrap = 1;
  187.         int update = assetmanageBLL.Insert(am);
  188.         if (update > 0)
  189.         {
  190.             this.Response.Write(string.Format(GetRedirect.WINALERT, "添加失败!"));
  191.         }
  192.         else
  193.         {
  194.             this.Response.Write(string.Format(GetRedirect.REDIRECT, "zclr2.aspx"));
  195.         }
  196.         this.Session.Add("am", am);
  197.     }
  198. }