ChargeDetailOther.aspx.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:9k
源码类别:

.net编程

开发平台:

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.SessionState;
  10. using System.ComponentModel;
  11. using System.Web.UI.WebControls.WebParts;
  12. using System.Web.UI.HtmlControls;
  13. using System.Data.SqlClient;
  14. using com.etong.BusinessRule.Zwf;
  15. using com.etong.DAL.FC;
  16. using com.etong.Inform;
  17. public partial class Workflow_ChargeDetailOther : System.Web.UI.Page
  18. {
  19.     protected int projectid = -1;
  20.     protected void Page_Load(object sender, EventArgs e)
  21.     {
  22.         Response.Buffer = true;
  23.         Response.ExpiresAbsolute = System.DateTime.Now;
  24.         Response.Expires = 0;
  25.         Response.CacheControl = "no-cache";
  26.         string project = Request.QueryString["projectid"].ToString();
  27.         //string project = "22";
  28.         if (project != "")
  29.             projectid = Convert.ToInt32(project);
  30.         else
  31.         {
  32.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:您尚未登录或您登录已超时,请重新登录');location.href='../../login.aspx'</script>");
  33.             return;
  34.         }
  35.         if (!IsPostBack)
  36.         {
  37.             ((HtmlInputHidden)Page.FindControl("status")).Value = "0"; //不可见状态
  38.             PanelAdd.Visible = false;
  39.             DataView dv = new DataView();
  40.             EtongFlyChouWFNM EFlyNM = new EtongFlyChouWFNM();
  41.             EFlyNM.Prj = projectid;
  42.             EFlyNM.sstatus = 1;
  43.             try
  44.             {
  45.                 dv = EFlyNM.ProOtherByPrj();
  46.             }
  47.             catch (Exception ex)
  48.             {
  49.                 this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "").Replace("n", "") + "');</script>");
  50.             }
  51.             GridView1.DataSource = dv;
  52.             GridView1.DataBind();
  53.         }
  54.     }
  55.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  56.     {
  57.         if (e.Row.RowIndex == 0)
  58.         {
  59.             ((HtmlInputHidden)Page.FindControl("txt_count")).Value = "0";
  60.         }
  61.         if (e.Row.RowType == DataControlRowType.DataRow)
  62.         {
  63.             decimal count = decimal.Parse(((HtmlInputHidden)Page.FindControl("txt_count")).Value.Trim());
  64.             ((HtmlInputHidden)Page.FindControl("txt_count")).Value = Convert.ToString(count + decimal.Parse(e.Row.Cells[3].Text.Trim()));
  65.         }
  66.     }
  67.     protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
  68.     {
  69.         EtongFlyChouWFNM EFlyNM = new EtongFlyChouWFNM();
  70.         try
  71.         {
  72.             EFlyNM.CommID = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString());
  73.         }
  74.         catch (Exception ex)
  75.         {
  76.             this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "").Replace("n", "") + "');</script>");
  77.             return;
  78.         }
  79.         EFlyNM.sstatus = 1;
  80.         CheckUserInfo UInfo = (CheckUserInfo)Session["checkuserinfo"];
  81.         EFlyNM.UserName = UInfo.EmpName;
  82.         try
  83.         {
  84.             EFlyNM.ProOtherDelete();
  85.         }
  86.         catch (Exception ex)
  87.         {
  88.             this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "").Replace("n", "") + "');</script>");
  89.             return;
  90.         }
  91.         DataView dv = new DataView();
  92.         EFlyNM.Prj = projectid;
  93.         EFlyNM.sstatus = 1;
  94.         try
  95.         {
  96.             dv = EFlyNM.ProOtherByPrj();
  97.         }
  98.         catch (Exception ex)
  99.         {
  100.             this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "").Replace("n", "") + "');</script>");
  101.         }
  102.         this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:删除成功!');", true);
  103.         GridView1.DataSource = dv;
  104.         GridView1.DataBind();
  105.     }
  106.     protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
  107.     {
  108.         PanelAdd.Visible = true;
  109.         ((HtmlInputHidden)Page.FindControl("status")).Value = "2"; //编辑状态
  110.         TB_OtherName.Text = GridView1.Rows[e.NewEditIndex].Cells[0].Text.Trim();
  111.         TB_Explain.Text = GridView1.Rows[e.NewEditIndex].Cells[1].Text.Trim();
  112.         TB_Memo.Text = GridView1.Rows[e.NewEditIndex].Cells[2].Text.Trim();
  113.         TB_Price.Text = GridView1.Rows[e.NewEditIndex].Cells[3].Text.Trim();
  114.    
  115.         ((HtmlInputHidden)Page.FindControl("equipmentid")).Value = GridView1.DataKeys[e.NewEditIndex].Value.ToString().Trim();  // DataKeyNames;
  116.     }
  117.     protected void BT_Confirm_Click(object sender, ImageClickEventArgs e)
  118.     {
  119.         EtongFlyChouWFNM EFlyNM = new EtongFlyChouWFNM();
  120.         EFlyNM.CommName = TB_OtherName.Text.Trim();
  121.         EFlyNM.Explain = TB_Explain.Text.Trim();
  122.         EFlyNM.Unit = TB_Memo.Text.Trim();
  123.         try
  124.         {
  125.             EFlyNM.DiffSum =decimal.Parse(TB_Price.Text.Trim());
  126.         }
  127.         catch
  128.         {
  129.             EFlyNM.DiffSum = 0;
  130.         }
  131.         if (EFlyNM.DiffSum == 0)
  132.         {
  133.             this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:金额错!');", true);
  134.             return;
  135.         }
  136.         EFlyNM.Prj = projectid;
  137.         CheckUserInfo UInfo = (CheckUserInfo)Session["checkuserinfo"];
  138.         EFlyNM.UserName = UInfo.EmpName;
  139.         string status = ((HtmlInputHidden)Page.FindControl("status")).Value;
  140.         if (status == "1")  // 新增
  141.         {
  142.             EFlyNM.status = 1;
  143.             try
  144.             {
  145.                 EFlyNM.ProOtherInsert();
  146.             }
  147.             catch (Exception ex)
  148.             {
  149.                 this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "").Replace("n", "") + "');</script>");
  150.                 return;
  151.             }
  152.             this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:新增成功!');", true);
  153.         }
  154.         else if (status == "2")  //编辑
  155.         {
  156.             EFlyNM.status = 2;
  157.             HtmlInputHidden txt_equipmentid = ((HtmlInputHidden)Page.FindControl("equipmentid"));
  158.             EFlyNM.CommID = Convert.ToInt32(txt_equipmentid.Value.Trim());
  159.             EFlyNM.sstatus = 1;
  160.             int err = 0;
  161.             try
  162.             {
  163.                 err = EFlyNM.ProOtherUpdata();
  164.             }
  165.             catch (Exception ex)
  166.             {
  167.                 this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "").Replace("n", "") + "');</script>");
  168.                 return;
  169.             }
  170.             if (err == -1)
  171.                 this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:更新成功!');", true);
  172.             else if (err == 1) this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('未找到要更新的内容,请查证后再试!');", true);
  173.             else if (err == 2) this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('未发生变化无需更新,请查证后再试!');", true);
  174.         }
  175.         //this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:操作成功!');", true);
  176.         DataView dv = new DataView();
  177.         EFlyNM.sstatus = 1;
  178.         try
  179.         {
  180.             dv = EFlyNM.ProOtherByPrj();
  181.         }
  182.         catch (Exception ex)
  183.         {
  184.             this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "").Replace("n", "") + "');</script>");
  185.             return;
  186.         }
  187.         GridView1.DataSource = dv;
  188.         GridView1.DataBind();
  189.         PanelAdd.Visible = false;
  190.         ClearText();
  191.     }
  192.     protected void BT_Cancel_Click(object sender, ImageClickEventArgs e)
  193.     {
  194.         PanelAdd.Visible = false;
  195.         ((HtmlInputHidden)Page.FindControl("status")).Value = "0"; //不可见状态
  196.         ClearText();
  197.     }
  198.     protected void BT_Add_Click(object sender, EventArgs e)
  199.     {
  200.         PanelAdd.Visible = true;
  201.         ((HtmlInputHidden)Page.FindControl("status")).Value = "1"; //新增状态
  202.     }
  203.     protected void ClearText()
  204.     {
  205.         TB_OtherName.Text = "";
  206.         TB_Explain.Text = "";
  207.         TB_Memo.Text = "";
  208.         TB_Price.Text = "0";
  209.     }
  210.     protected void IB_Search_Click(object sender, ImageClickEventArgs e)
  211.     {
  212.     }
  213.     protected void IB_Add_Click(object sender, ImageClickEventArgs e)
  214.     {
  215.         PanelAdd.Visible = true;
  216.         ((HtmlInputHidden)Page.FindControl("status")).Value = "1"; //新增状态
  217.     }
  218. }