ChargeDetailOther.aspx.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:9k
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.SessionState;
- using System.ComponentModel;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using System.Data.SqlClient;
- using com.etong.BusinessRule.Zwf;
- using com.etong.DAL.FC;
- using com.etong.Inform;
- public partial class Workflow_ChargeDetailOther : System.Web.UI.Page
- {
- protected int projectid = -1;
- protected void Page_Load(object sender, EventArgs e)
- {
- Response.Buffer = true;
- Response.ExpiresAbsolute = System.DateTime.Now;
- Response.Expires = 0;
- Response.CacheControl = "no-cache";
- string project = Request.QueryString["projectid"].ToString();
- //string project = "22";
- if (project != "")
- projectid = Convert.ToInt32(project);
- else
- {
- ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:您尚未登录或您登录已超时,请重新登录');location.href='../../login.aspx'</script>");
- return;
- }
- if (!IsPostBack)
- {
- ((HtmlInputHidden)Page.FindControl("status")).Value = "0"; //不可见状态
- PanelAdd.Visible = false;
- DataView dv = new DataView();
- EtongFlyChouWFNM EFlyNM = new EtongFlyChouWFNM();
- EFlyNM.Prj = projectid;
- EFlyNM.sstatus = 1;
- try
- {
- dv = EFlyNM.ProOtherByPrj();
- }
- catch (Exception ex)
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "").Replace("n", "") + "');</script>");
- }
- GridView1.DataSource = dv;
- GridView1.DataBind();
- }
- }
- protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- if (e.Row.RowIndex == 0)
- {
- ((HtmlInputHidden)Page.FindControl("txt_count")).Value = "0";
- }
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- decimal count = decimal.Parse(((HtmlInputHidden)Page.FindControl("txt_count")).Value.Trim());
- ((HtmlInputHidden)Page.FindControl("txt_count")).Value = Convert.ToString(count + decimal.Parse(e.Row.Cells[3].Text.Trim()));
- }
- }
- protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
- {
- EtongFlyChouWFNM EFlyNM = new EtongFlyChouWFNM();
- try
- {
- EFlyNM.CommID = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString());
- }
- catch (Exception ex)
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "").Replace("n", "") + "');</script>");
- return;
- }
- EFlyNM.sstatus = 1;
- CheckUserInfo UInfo = (CheckUserInfo)Session["checkuserinfo"];
- EFlyNM.UserName = UInfo.EmpName;
- try
- {
- EFlyNM.ProOtherDelete();
- }
- catch (Exception ex)
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "").Replace("n", "") + "');</script>");
- return;
- }
- DataView dv = new DataView();
- EFlyNM.Prj = projectid;
- EFlyNM.sstatus = 1;
- try
- {
- dv = EFlyNM.ProOtherByPrj();
- }
- catch (Exception ex)
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "").Replace("n", "") + "');</script>");
- }
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:删除成功!');", true);
- GridView1.DataSource = dv;
- GridView1.DataBind();
- }
- protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
- {
- PanelAdd.Visible = true;
- ((HtmlInputHidden)Page.FindControl("status")).Value = "2"; //编辑状态
- TB_OtherName.Text = GridView1.Rows[e.NewEditIndex].Cells[0].Text.Trim();
- TB_Explain.Text = GridView1.Rows[e.NewEditIndex].Cells[1].Text.Trim();
- TB_Memo.Text = GridView1.Rows[e.NewEditIndex].Cells[2].Text.Trim();
- TB_Price.Text = GridView1.Rows[e.NewEditIndex].Cells[3].Text.Trim();
-
- ((HtmlInputHidden)Page.FindControl("equipmentid")).Value = GridView1.DataKeys[e.NewEditIndex].Value.ToString().Trim(); // DataKeyNames;
- }
- protected void BT_Confirm_Click(object sender, ImageClickEventArgs e)
- {
- EtongFlyChouWFNM EFlyNM = new EtongFlyChouWFNM();
- EFlyNM.CommName = TB_OtherName.Text.Trim();
- EFlyNM.Explain = TB_Explain.Text.Trim();
- EFlyNM.Unit = TB_Memo.Text.Trim();
- try
- {
- EFlyNM.DiffSum =decimal.Parse(TB_Price.Text.Trim());
- }
- catch
- {
- EFlyNM.DiffSum = 0;
- }
- if (EFlyNM.DiffSum == 0)
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:金额错!');", true);
- return;
- }
- EFlyNM.Prj = projectid;
- CheckUserInfo UInfo = (CheckUserInfo)Session["checkuserinfo"];
- EFlyNM.UserName = UInfo.EmpName;
- string status = ((HtmlInputHidden)Page.FindControl("status")).Value;
- if (status == "1") // 新增
- {
- EFlyNM.status = 1;
- try
- {
- EFlyNM.ProOtherInsert();
- }
- catch (Exception ex)
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "").Replace("n", "") + "');</script>");
- return;
- }
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:新增成功!');", true);
- }
- else if (status == "2") //编辑
- {
- EFlyNM.status = 2;
- HtmlInputHidden txt_equipmentid = ((HtmlInputHidden)Page.FindControl("equipmentid"));
- EFlyNM.CommID = Convert.ToInt32(txt_equipmentid.Value.Trim());
- EFlyNM.sstatus = 1;
- int err = 0;
- try
- {
- err = EFlyNM.ProOtherUpdata();
- }
- catch (Exception ex)
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "").Replace("n", "") + "');</script>");
- return;
- }
- if (err == -1)
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:更新成功!');", true);
- else if (err == 1) this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('未找到要更新的内容,请查证后再试!');", true);
- else if (err == 2) this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('未发生变化无需更新,请查证后再试!');", true);
- }
- //this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:操作成功!');", true);
- DataView dv = new DataView();
- EFlyNM.sstatus = 1;
- try
- {
- dv = EFlyNM.ProOtherByPrj();
- }
- catch (Exception ex)
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "").Replace("n", "") + "');</script>");
- return;
- }
- GridView1.DataSource = dv;
- GridView1.DataBind();
- PanelAdd.Visible = false;
- ClearText();
- }
- protected void BT_Cancel_Click(object sender, ImageClickEventArgs e)
- {
- PanelAdd.Visible = false;
- ((HtmlInputHidden)Page.FindControl("status")).Value = "0"; //不可见状态
- ClearText();
- }
- protected void BT_Add_Click(object sender, EventArgs e)
- {
- PanelAdd.Visible = true;
- ((HtmlInputHidden)Page.FindControl("status")).Value = "1"; //新增状态
- }
- protected void ClearText()
- {
- TB_OtherName.Text = "";
- TB_Explain.Text = "";
- TB_Memo.Text = "";
- TB_Price.Text = "0";
- }
- protected void IB_Search_Click(object sender, ImageClickEventArgs e)
- {
- }
- protected void IB_Add_Click(object sender, ImageClickEventArgs e)
- {
- PanelAdd.Visible = true;
- ((HtmlInputHidden)Page.FindControl("status")).Value = "1"; //新增状态
- }
- }