ChargeDetailEq.aspx.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:15k
- 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_ChargeDetailEq : 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"; //不可见状态
- ((HtmlInputHidden)Page.FindControl("TxtSeacher")).Value = "1";
- PanelAdd.Visible = false;
- EtongFlyChouWFNM EFlyNM = new EtongFlyChouWFNM();
- EFlyNM.Prj = projectid;
- EFlyNM.sstatus = 1;
- DataView dv = new DataView();
- try
- {
- dv = EFlyNM.ProEquGetData();
- }
- catch (Exception ex)
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "").Replace("n", "") + "');</script>");
- return;
- }
- GridView1.DataSource = dv;
- GridView1.DataBind();
- BindParent();
- dListChild.Attributes.Add("onchange","javascript:return DListChange()");
- RBL_Type.Attributes.Add("onclick", "javascript:return DBLChange()");
- TB_SearchContent.Attributes.Add("onkeypress", "EnterTextBox()");
- }
-
- }
- protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
- {
- PanelAdd.Visible = true;
-
- ((HtmlInputHidden)Page.FindControl("status")).Value="2"; //编辑状态
- dListParent.SelectedItem.Text= GridView1.Rows[e.NewEditIndex].Cells[0].Text.Trim();
- string dListParentid = dListParent.SelectedValue;
- BindChild(dListParentid);
- dListChild.SelectedItem.Text = GridView1.Rows[e.NewEditIndex].Cells[1].Text.Trim();
- TB_wz.Text = GridView1.Rows[e.NewEditIndex].Cells[2].Text.ToString();
- TB_UnitName.Text = GridView1.Rows[e.NewEditIndex].Cells[3].Text.Trim();
- TB_Price.Text = GridView1.Rows[e.NewEditIndex].Cells[4].Text.Trim();
- TB_Number.Text = GridView1.Rows[e.NewEditIndex].Cells[5].Text.Trim();
- TB_Count.Text = GridView1.Rows[e.NewEditIndex].Cells[6].Text.Trim();
- ((HtmlInputHidden)Page.FindControl("equipmentid")).Value = GridView1.DataKeys[e.NewEditIndex].Value.ToString().Trim(); // DataKeyNames;
- }
- protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
- {
- int equipmentid = Convert.ToInt16(GridView1.DataKeys[e.RowIndex].Value.ToString());
- EtongFlyChouWFNM EFlyNM = new EtongFlyChouWFNM();
- EFlyNM.CommID = equipmentid;
- EFlyNM.sstatus = 1;
- CheckUserInfo UInfo = (CheckUserInfo)Session["checkuserinfo"];
- EFlyNM.UserName = UInfo.EmpName;
- try
- {
- EFlyNM.ProEquDelete();
- }
- 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);
- ((HtmlInputHidden)Page.FindControl("txtcount")).Value = "0";
- EFlyNM.Prj = projectid;
- EFlyNM.sstatus = 1;
- DataView dv = new DataView();
- try
- {
- dv = EFlyNM.ProEquGetData();
- }
- catch (Exception ex)
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "").Replace("n", "") + "');</script>");
- return;
- }
- GridView1.DataSource = dv;
- GridView1.DataBind();
- }
-
- protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- if (e.Row.RowIndex == 0)
- {
- ((HtmlInputHidden)Page.FindControl("txtcount")).Value = "0";
- }
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- decimal p=decimal.Parse(e.Row.Cells[4].Text.Trim());
- int n=Convert.ToInt32(e.Row.Cells[5].Text.Trim());
- e.Row.Cells[6].Text = Convert.ToString(p * n);
- decimal count = decimal.Parse(((HtmlInputHidden)Page.FindControl("txtcount")).Value.Trim());
- ((HtmlInputHidden)Page.FindControl("txtcount")).Value = Convert.ToString(count + decimal.Parse(e.Row.Cells[6].Text.Trim()));
- }
- }
- protected void BT_Confirm_Click(object sender, ImageClickEventArgs e)
- {
-
- PanelAdd.Visible = false;
- string EquipmentName = dListParent.SelectedItem.Text.Trim();
- string dListParentid = dListParent.SelectedValue.Trim();
- string EquipmentSize = dListChild.SelectedItem.Text.Trim(); //--设备规格与型号
- string UnitName = TB_UnitName.Text.Trim();
- int wz_id = Convert.ToInt32(dListChild.SelectedValue.Trim());
- int Number;
- // if(TB_Number.Text.Trim()!="") Number = Convert.ToInt32(TB_Number.Text.Trim());
-
- try
- {
- Number = Convert.ToInt32(TB_Number.Text.Trim());
- }
- catch
- {
- Number = 0;
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:数量必需大于零,提交失败!');", true);
- return;
- }
- decimal Price;
- // if (TB_Price.Text.Trim()!="") Price= decimal.Parse(TB_Price.Text.Trim());
- try
- {
- Price = decimal.Parse(TB_Price.Text.Trim());
- }
- catch
- {
- Price = 0;
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:单价必需大于零,提交失败!');", true);
- return;
- }
- EtongFlyChouWFNM EFlyNM = new EtongFlyChouWFNM();
- EFlyNM.Unit = UnitName;
- EFlyNM.WZ = wz_id;
- EFlyNM.CommName = EquipmentName;
- EFlyNM.Num = Number;
- EFlyNM.Prj = projectid;
- EFlyNM.Mark = Price;
- EFlyNM.CommSize = EquipmentSize;
- CheckUserInfo UInfo = (CheckUserInfo)Session["checkuserinfo"];
- EFlyNM.UserName = UInfo.EmpName;
-
- string status = ((HtmlInputHidden)Page.FindControl("status")).Value;
- if (status == "1") // 新增
- {
- int err = 1;
- EFlyNM.status = 1;
- try
- {
- err=EFlyNM.ProEquInsert();
- }
- 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);
- return;
- }
- else
- 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.ProEquUpdate();
- }
- 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);
- }
- else
- {
- return;
- }
- EFlyNM.sstatus = 1;
- DataView dv = new DataView();
- try
- {
- dv = EFlyNM.ProEquGetData();
- }
- catch (Exception ex)
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "").Replace("n", "") + "');</script>");
- return;
- }
- GridView1.DataSource = dv;
- GridView1.DataBind();
- TB_UnitName.Text = "";
- TB_Price.Text = "0";
- TB_Number.Text = "1";
- TB_Count.Text = "0";
- ((HtmlInputHidden)Page.FindControl("status")).Value = "0"; //不可见状态
- }
- protected void BT_Cancel_Click(object sender, ImageClickEventArgs e)
- {
- PanelAdd.Visible = false;
- ((HtmlInputHidden)Page.FindControl("status")).Value = "0"; //不可见状态
- TB_UnitName.Text = "";
- TB_Price.Text = "";
- TB_Number.Text = "";
- TB_Count.Text = "";
- }
- protected void BindParent()
- {
- DataView dv = new DataView();
- EtongFlyChouWFNM EFlyNM = new EtongFlyChouWFNM();
- dv = EFlyNM.GetBigWZList();
- for (int i=0;i<dv.Table.Rows.Count;i++)
- {
- dListParent.Items.Add(new ListItem(dv.Table.Rows[i][2].ToString(),dv.Table.Rows[i][0].ToString()+dv.Table.Rows[i][1].ToString()));
- }
- dListParent.Items[0].Selected = true;
- string str1 = dListParent.SelectedValue;
- BindChild(str1);
- }
- protected void BindChild(string str)
- {
- str = "material_name where wz_id like '" +str + "%'";
- EtongFlyChouCode EFlyCode = new EtongFlyChouCode();
- DataView dv = EFlyCode.BStringSelect("wz_id,wz_spec",str,2);
- //string commStr = string.Format("select wz_id,wz_spec from material_name where wz_id like '{0}'", str);
- dListChild.DataSource = dv;
- dListChild.DataTextField = "wz_spec";
- dListChild.DataValueField = "wz_id";
- dListChild.DataBind();
- TB_wz.Text = dListChild.SelectedValue.ToString();
- }
- protected void dListParent_SelectedIndexChanged(object sender, EventArgs e)
- {
- string dListParentid = dListParent.SelectedValue;
- BindChild(dListParentid);
- }
- protected void IB_Search_Click(object sender, ImageClickEventArgs e)
- {
- int iSearch;
- try
- {
- iSearch= Convert.ToInt32(RBL_Type.SelectedValue.Trim());
- }
- catch
- {
- iSearch =0;
- }
- string strContent=TB_SearchContent.Text.Trim();
- string sFiled = "wz_id,wz_name,wz_spec";
- string sTable = "material_name where ";
- DataView dv = new DataView();
- EtongFlyChouCode EFlyCode = new EtongFlyChouCode();
- if (iSearch == 1)
- {
- Int64 iContent;
- try
- {
- iContent = Convert.ToInt64(strContent);
- }
- catch
- {
- iContent = -1;
- }
- sTable = sTable + "wz_id=" + iContent.ToString();
- dv = EFlyCode.BStringSelect(sFiled, sTable, 2);
- if (dv.Table.Rows.Count > 0)
- {
- if (iSearch == 1)
- {
- if (((HtmlInputHidden)Page.FindControl("status")).Value == "0") ((HtmlInputHidden)Page.FindControl("status")).Value = "1";
- PanelAdd.Visible = true;
- dListParent.Items.FindByValue(dListParent.SelectedValue).Selected = false;
- dListParent.Items.FindByValue(dv.Table.Rows[0][0].ToString().Substring(0, 4)).Selected = true;
- BindChild(dv.Table.Rows[0][0].ToString().Substring(0, 4));
- dListChild.Items.FindByValue(dListChild.SelectedValue).Selected = false;
- dListChild.Items.FindByValue(dv.Table.Rows[0][0].ToString()).Selected = true;
- TB_wz.Text = dv.Table.Rows[0][0].ToString();
- }
- }
- else
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:未找到对应的物资代码!');",true);
- }
- }//isercher 1
- else if (iSearch == 2)
- {
- if (((HtmlInputHidden)Page.FindControl("status")).Value == "0") ((HtmlInputHidden)Page.FindControl("status")).Value = "1";
- PanelAdd.Visible = true;
- dListParent.Items.FindByValue(dListParent.SelectedValue).Selected = false;
- dListParent.Items.FindByValue(TxtWZ.Value.ToString().Substring(0, 4)).Selected = true;
- BindChild(TxtWZ.Value.ToString().Substring(0, 4));
- dListChild.Items.FindByValue(dListChild.SelectedValue).Selected = false;
- dListChild.Items.FindByValue(TxtWZ.Value.ToString()).Selected = true;
- TB_wz.Text = TxtWZ.Value.ToString();
- }
- }
- protected void IB_Add_Click(object sender, ImageClickEventArgs e)
- {
- PanelAdd.Visible = true;
- ((HtmlInputHidden)Page.FindControl("status")).Value = "1"; //新增状态
- }
- //protected void dListChild_SelectedIndexChanged(object sender, EventArgs e)
- //{
- // TB_wz.Text = dListChild.SelectedValue.ToString();
- //}
- }