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

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.BLL;
  12. using System.Collections.Generic;
  13. using COM.OA.Entity;
  14. public partial class wc_zcgl_zcxg : System.Web.UI.Page
  15. {
  16.     protected void Page_Load(object sender, EventArgs e)
  17.     {
  18.         users loginuser = Session["loginuser"] as users;
  19.         if (loginuser == null)
  20.         {
  21.             this.Response.Write(string.Format(GetRedirect.ALLREDIRECT, "../login.aspx"));
  22.         }
  23.         else
  24.         {
  25.             if (!IsPostBack)
  26.             {
  27.                 int xid = Int32.Parse(this.Request["xid"]);
  28.                 string where = "am_id=" + xid;
  29.                 IList<assetmanage> amlist = assetmanageBLL.Select(where);
  30.                 assetmanage am = new assetmanage();
  31.                 if (amlist.Count != 0)
  32.                 {
  33.                     am = amlist[0];
  34.                     this.txtAssetname.Text = am.am_assetname;
  35.                     this.txtNumber.Text = am.am_number;
  36.                     this.txtMeasureunit.Text = am.am_measureunit;
  37.                     this.txtScalar.Text = am.am_scalar.ToString();
  38.                     if (am.am_spectype.Equals("0"))
  39.                     {
  40.                         this.txtSpectype.Text = "";
  41.                     }
  42.                     else
  43.                     {
  44.                         this.txtSpectype.Text = am.am_spectype;
  45.                     }
  46.                     if (am.am_leavefactorynumber.Equals("0"))
  47.                     {
  48.                         this.txtLeaveFactoryNumber.Text = "";
  49.                     }
  50.                     else
  51.                     {
  52.                         this.txtLeaveFactoryNumber.Text = am.am_leavefactorynumber;
  53.                     }
  54.                     if (am.am_artletternumber.Equals("0"))
  55.                     {
  56.                         this.txtArtletterNumber.Text = "";
  57.                     }
  58.                     else
  59.                     {
  60.                         this.txtArtletterNumber.Text = am.am_artletternumber;
  61.                     }
  62.                     this.txtBuyPrice.Text = am.am_buyprice.ToString();
  63.                     if (am.am_installcost == 0)
  64.                     {
  65.                         this.txtInstallcost.Text = "";
  66.                     }
  67.                     else
  68.                     {
  69.                         this.txtInstallcost.Text = am.am_installcost.ToString();
  70.                     }
  71.                     if (am.am_depreciationcost == 0)
  72.                     {
  73.                         this.txtDepreciationcost.Text = "";
  74.                     }
  75.                     else
  76.                     {
  77.                         this.txtDepreciationcost.Text = am.am_depreciationcost.ToString();
  78.                     }
  79.                     if (am.am_betvalue == 0)
  80.                     {
  81.                         this.txtBetvalue.Text = "";
  82.                     }
  83.                     else
  84.                     {
  85.                         this.txtBetvalue.Text = am.am_betvalue.ToString();
  86.                     }
  87.                     this.txtProduction.Text = am.am_production;
  88.                     if (am.am_productiondate.ToString("yyyy-MM-dd").Equals("1753-01-01"))
  89.                     {
  90.                         this.wdproductiondate.Text = "";
  91.                     }
  92.                     else
  93.                     {
  94.                         this.wdproductiondate.Text = am.am_productiondate.ToString("yyyy-MM-dd");
  95.                     }
  96.                     this.wddeliverusetim.Text = am.am_deliverusetime.ToString("yyyy-MM-dd");
  97.                     if (am.am_advanceuseyear == 0)
  98.                     {
  99.                         this.txtAdvanceuseyear.Text = "";
  100.                     }
  101.                     else
  102.                     {
  103.                         this.txtAdvanceuseyear.Text = am.am_advanceuseyear.ToString();
  104.                     }
  105.                     this.txtBuyordept.Text = am.am_buyordept;
  106.                     this.txtStorageordept.Text = am.am_storageordept;
  107.                     this.txtPurpose.Text = am.am_purpose;
  108.                     if (!IsPostBack)
  109.                     {
  110.                         this.ddDept.SelectedIndex = am.am_dept_id - 1;
  111.                     }
  112.                     this.txtUseaddress.Text = am.am_useaddress;
  113.                     if (am.am_usestate == 0)
  114.                     {
  115.                         this.txtUsestate.Text = "未使用";
  116.                     }
  117.                     else
  118.                     {
  119.                         this.txtUsestate.Text = "使用中";
  120.                     }
  121.                     //录入人
  122.                     int bid = am.am_bookerid;
  123.                     string bwhere = "u_id=" + bid;
  124.                     IList<users> userilist = usersBLL.Select(bwhere);
  125.                     List<users> userlist = (List<users>)userilist;
  126.                     users us = new users();
  127.                     us = userlist[0];
  128.                     int emid = us.u_em_id;
  129.                     string whereem = "em_id=" + emid;
  130.                     IList<employee> emilist = employeeBLL.Select(whereem);
  131.                     List<employee> emlist = (List<employee>)emilist;
  132.                     employee em = new employee();
  133.                     em = emlist[0];
  134.                     this.txtBookerid.Text = em.em_name;
  135.                     this.txtRemark.Text = am.am_remark;
  136.                     int aaaa = am.am_isscrap;
  137.                     if (am.am_isscrap == 0)
  138.                     {
  139.                         this.rbno.Checked = false;
  140.                         this.rbis.Checked = true;
  141.                     }
  142.                     else if (am.am_isscrap == 1)
  143.                     {
  144.                         this.rbno.Checked = true;
  145.                         this.rbis.Checked = false;
  146.                     }
  147.                 }
  148.             }
  149.     }
  150.     
  151.     }
  152.     protected void btnSubmit_Click(object sender, EventArgs e)
  153.     {
  154.         if (IsPostBack) { 
  155.             string Assetname = this.txtAssetname.Text;//资产名称
  156.             string Number = this.txtNumber.Text;//编号
  157.             string Measureunit = this.txtMeasureunit.Text;//计量单位
  158.             string s = this.txtScalar.Text; //数量
  159.             int Scalar;
  160.             if (s.Equals(""))
  161.             {
  162.                 Scalar = 0;
  163.             }
  164.             else
  165.             {
  166.                 Scalar = Int32.Parse(this.txtScalar.Text);
  167.             }
  168.             string Spectype = this.txtSpectype.Text;//规格型号
  169.             string LeaveFactoryNumber = this.txtLeaveFactoryNumber.Text;//出厂编号
  170.             string ArtletterNumber = this.txtArtletterNumber.Text;//技术证书号
  171.             string b = this.txtBuyPrice.Text;//购买价格
  172.             float BuyPrice;
  173.             if (b.Equals(""))
  174.             {
  175.                 BuyPrice = 0;
  176.             }
  177.             else
  178.             {
  179.                 BuyPrice = float.Parse(this.txtBuyPrice.Text);
  180.             }
  181.             string i = this.txtInstallcost.Text;//安装费
  182.             float Installcost;
  183.             if (i.Equals(""))
  184.             {
  185.                 Installcost = 0;
  186.             }
  187.             else
  188.             {
  189.                 Installcost = float.Parse(this.txtInstallcost.Text);
  190.             }
  191.             string d = this.txtDepreciationcost.Text;//折旧
  192.             float Depreciationcost;
  193.             if (d.Equals(""))
  194.             {
  195.                 Depreciationcost = 0;
  196.             }
  197.             else
  198.             {
  199.                 Depreciationcost = float.Parse(this.txtDepreciationcost.Text);
  200.             }
  201.             string bv = this.txtBetvalue.Text;//净值
  202.             float Betvalue;
  203.             if (bv.Equals(""))
  204.             {
  205.                 Betvalue = 0;
  206.             }
  207.             else
  208.             {
  209.                 Betvalue = float.Parse(this.txtBetvalue.Text);
  210.             }
  211.             string Production = this.txtProduction.Text;//生产单位
  212.             string Productiondate = this.wdproductiondate.Text;//生产年月
  213.             DateTime pdate;
  214.             if (Productiondate.Equals(""))
  215.             {
  216.                 pdate = DateTime.Parse("1753-1-1");
  217.             }
  218.             else
  219.             {
  220.                 pdate = DateTime.Parse(this.wdproductiondate.Text);
  221.             }
  222.             string Deliverusetime = this.wddeliverusetim.Text;//交付使用日期
  223.             DateTime dtime;
  224.             if (Deliverusetime.Equals(""))
  225.             {
  226.                 dtime = DateTime.Parse("1753-1-1");
  227.             }
  228.             else
  229.             {
  230.                 dtime = DateTime.Parse(this.wddeliverusetim.Text);
  231.             }
  232.             string a = this.txtAdvanceuseyear.Text;//预计使用年限
  233.             int Advanceuseyear;
  234.             if (a.Equals(""))
  235.             {
  236.                 Advanceuseyear = 0;
  237.             }
  238.             else
  239.             {
  240.                 Advanceuseyear = Int32.Parse(this.txtAdvanceuseyear.Text);
  241.             }
  242.             string Buyordept = this.txtBuyordept.Text;//请购人或部门
  243.             string Storageordept = this.txtStorageordept.Text;//保管人或部门
  244.             string Purpose = this.txtPurpose.Text;//用途
  245.             int Dept = Int32.Parse(this.ddDept.Text);//使用部门
  246.             string Useaddress = this.txtUseaddress.Text;//使用地点
  247.             string u = this.txtUsestate.Text;//使用状态
  248.             int Usestate;
  249.             if (u.Equals("使用中"))
  250.             {
  251.                 Usestate = 1;
  252.             }
  253.             else
  254.             {
  255.                 Usestate = 0;
  256.             }
  257.             int Bookerid = Int32.Parse(this.txtLoginid.Text);//录入人
  258.             string Remark = this.txtRemark.Text;//备注
  259.             DateTime Registertime = DateTime.Now;//录入时间       
  260.             assetmanage am = new assetmanage();
  261.             int xid = Int32.Parse(this.Request["xid"]);
  262.             am.am_assetname = Assetname;
  263.             am.am_number = Number;
  264.             am.am_measureunit = Measureunit;
  265.             am.am_scalar = Scalar;
  266.             am.am_spectype = Spectype;
  267.             am.am_leavefactorynumber = LeaveFactoryNumber;
  268.             am.am_artletternumber = ArtletterNumber;
  269.             am.am_buyprice = BuyPrice;
  270.             am.am_installcost = Installcost;
  271.             am.am_depreciationcost = Depreciationcost;
  272.             am.am_betvalue = Betvalue;
  273.             am.am_production = Production;
  274.             am.am_productiondate = pdate;
  275.             am.am_deliverusetime = dtime;
  276.             am.am_advanceuseyear = Advanceuseyear;
  277.             am.am_buyordept = Buyordept;
  278.             am.am_storageordept = Storageordept;
  279.             am.am_purpose = Purpose;
  280.             am.am_dept_id = Dept;
  281.             am.am_useaddress = Useaddress;
  282.             am.am_usestate = Usestate;
  283.             am.am_registertime = Registertime;
  284.             users loginuser = Session["loginuser"] as users;
  285.             int bookid = loginuser.u_id;
  286.             am.am_bookerid = bookid;
  287.             am.am_remark = Remark;
  288.             am.am_id = xid;
  289.             int isscrap = 0;
  290.             if (this.rbis.Checked == true)
  291.             {
  292.                 
  293.                 isscrap = 0;
  294.             }
  295.             else if(this.rbno.Checked == true)
  296.             {
  297.                 isscrap = 1;
  298.             }
  299.             am.am_isscrap = isscrap;
  300.             
  301.             
  302.             int update = assetmanageBLL.Update(am);
  303.             if (update > 0)
  304.             {
  305.                 this.Response.Write(string.Format(GetRedirect.WINALERT, "修改失败!"));
  306.             }
  307.             else
  308.             {
  309.                 this.Response.Write(string.Format(GetRedirect.WINALERT, "修改成功!"));
  310.                 this.Response.Write(string.Format(GetRedirect.REDIRECT, "zclb.aspx"));
  311.             }
  312.         }   
  313.     }
  314. }