using System; using System.Collections; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Text; using DSWeb.DataAccess; using System.Data.SqlClient; using DSWeb.Models; using DSWeb.EntityDA; using System.Web.Script.Serialization; namespace DSWeb.Shipping { public partial class InfoShipper : System.Web.UI.Page { public string strHandleType = String.Empty; public string sSQL = String.Empty; public string gvid = String.Empty; T_ALL_DA T_ALL_DA = new T_ALL_DA(); MoneyConvert MoneyConvert = new MoneyConvert(); TopSeaeEntity TopSeaeEntity = new TopSeaeEntity(); SeaExportInfoDA SeaExportInfoDA = new SeaExportInfoDA(); RangeDA RangeDA = new RangeDA(); public string strUserID;//用户GID protected void Page_Load(object sender, EventArgs e) { if (Session["USERID"] != null) { strUserID = Session["USERID"].ToString().Trim(); } else { Server.Transfer("~/Error/FriendError.aspx"); return; //strUserID = ""; } // if (!IsPostBack) { if (Request.QueryString["handle"] != null) //if (Request.QueryString["handle"] != null) { ViewState["shipperID"] = ""; ViewState["strHandleType"] = ""; strHandleType = ViewState["strHandleType"].ToString().Trim(); if (Request.QueryString["id"] != null)//if (Request.QueryString["id"] != null) { ViewState["GID"] = Request.QueryString["id"].ToString();//"topseaeusername129481962859531250"; if (ViewState["GID"].ToString().Trim() != "") { string strISCONTROLLER = T_ALL_DA.GetStrSQL("ISCONTROLLER", "select ISCONTROLLER from info_client where GID='" + ViewState["GID"].ToString().Trim() + "'"); if (strISCONTROLLER.Trim() == "True") { ViewState["codename"] = T_ALL_DA.GetStrSQL("codename", "select codename from info_client where GID='" + ViewState["GID"].ToString().Trim() + "'"); // Panel1.Visible = false; ibAdd.Enabled = true; ibEnter.Enabled = false; Panel2.Visible = false; } else { Panel1.Visible = false; ibAdd.Enabled = false; ibEnter.Enabled = false; Panel2.Visible = true; } } else { getEnabled(); } } else { getEnabled(); } // getDLInfoShipper(); } else { } //权限可视范围 string strV = RangeDA.GetVISIBLERANGE(strUserID.Trim(), "modExchangesUnit"); string strO = RangeDA.GetOPERATERANGE(strUserID.Trim(), "modExchangesUnit"); string alt = ""; if (strV.Trim().Equals("4"))//全部 { ibAdd.Enabled = true; } else if (strV.Trim().Equals("1"))//分公司 { if (strO.Trim().Equals("1"))//公司 { alt = RangeDA.GetUnitCompany(strUserID.Trim(), ViewState["GID"].ToString().Trim()); if (alt == "") { getEnabled(); } } else if (strO.Trim().Equals("3"))//个人 { alt = RangeDA.GetUnitPerson(strUserID.Trim(), ViewState["GID"].ToString().Trim()); if (alt == "") { getEnabled(); } } } else if (strV.Trim().Equals("3")) { if (strO.Trim().Equals("3"))//个人 { alt = RangeDA.GetUnitPerson(strUserID.Trim(), ViewState["GID"].ToString().Trim()); if (alt == "") { getEnabled(); } } else if (strO.Trim().Equals("4"))//无 { getEnabled(); } } // } } protected void getEnabled() { ibAdd.Enabled = false; ibEnter.Enabled = false; dlInfoShipper.Enabled = false; // tbshipperID.Enabled = false; tbSHORTNAME.Enabled = false; RadioButtonList1.Enabled = false; cbISPUBLIC.Enabled = false; txtshipperdetail.Disabled = true; txtloadAddress.Disabled = true; txtdeliveraddress.Disabled = true; } protected void getDLInfoShipper() { if (ViewState["codename"]!=null && ViewState["codename"].ToString().Trim() != "") { DataSet ds = T_ALL_DA.GetInfoShipper(ViewState["codename"].ToString().Trim()); dlInfoShipper.DataSource = ds; dlInfoShipper.DataBind(); } } protected bool getAdd() { string alt = ""; alt = T_ALL_DA.GetInfoShipperInsert(ViewState["codename"].ToString().Trim(), tbshipperID.Text.Trim(), tbSHORTNAME.Text.Trim(), int.Parse(RadioButtonList1.SelectedValue.Trim()),txtshipperdetail.Value.Trim().Replace("'", "’"), strUserID.Trim(),txtloadAddress.Value.Trim(),txtdeliveraddress.Value.Trim(), cbISPUBLIC.Checked); if (alt == "") { ViewState["strHandleType"] = "edit"; return true; } else { return false; } } protected bool getEdit() { string alt = ""; alt = T_ALL_DA.GetInfoShipperUpdate(ViewState["codename"].ToString().Trim(), tbshipperID.Text.Trim(), tbSHORTNAME.Text.Trim(), int.Parse(RadioButtonList1.SelectedValue.Trim()), txtshipperdetail.Value.Trim().Replace("'", "’"), ViewState["shipperID"].ToString().Trim(), strUserID.Trim(), txtloadAddress.Value.Trim(), txtdeliveraddress.Value.Trim(), cbISPUBLIC.Checked); if (alt == "") { ViewState["strHandleType"] = "edit"; return true; } else { return false; } } protected void btnEnter_Click(object sender, EventArgs e) { if (tbshipperID.Text.Trim() == "") { System.Web.UI.ScriptManager.RegisterStartupScript(this.UpdatePanel3, this.GetType(), "unReport30", "alert('客户代码不允许为空!');", true); return; } if (tbSHORTNAME.Text.Trim() == "") { System.Web.UI.ScriptManager.RegisterStartupScript(this.UpdatePanel3, this.GetType(), "unReport30", "alert('客户简称不允许为空!');", true); return; } bool bl = false; strHandleType = ViewState["strHandleType"].ToString().Trim(); if (strHandleType.Equals("add"))//新增 { DataSet ds = T_ALL_DA.GetInfoShipperSQL(" and shipperID='" + tbshipperID.Text.Trim() + "'"); if (ds != null) { if (ds.Tables[0].Rows[0]["shipperID"].ToString().Trim() != "") { System.Web.UI.ScriptManager.RegisterStartupScript(this.UpdatePanel3, this.GetType(), "unReport30", "alert('客户代码重复,请重新填写!');", true); return; } } // ds = T_ALL_DA.GetInfoShipperSQL(" and SHORTNAME='" + tbSHORTNAME.Text.Trim() + "'"); if (ds != null) { if (ds.Tables[0].Rows[0]["SHORTNAME"].ToString().Trim() != "") { System.Web.UI.ScriptManager.RegisterStartupScript(this.UpdatePanel3, this.GetType(), "unReport30", "alert('客户简称重复,请重新填写!');", true); return; } } // bl = getAdd(); } else if (strHandleType.Equals("edit"))//录入 { DataSet ds = T_ALL_DA.GetInfoShipperSQL(" and shipperID='" + tbshipperID.Text.Trim() + "' and codename<>'" + ViewState["codename"].ToString().Trim() + "'"); if (ds != null) { if (ds.Tables[0].Rows[0]["shipperID"].ToString().Trim() != "") { System.Web.UI.ScriptManager.RegisterStartupScript(this.UpdatePanel3, this.GetType(), "unReport30", "alert('客户代码重复,请重新填写!');", true); return; } } // ds = T_ALL_DA.GetInfoShipperSQL(" and SHORTNAME='" + tbSHORTNAME.Text.Trim() + "' and codename<>'" + ViewState["codename"].ToString().Trim() + "'"); if (ds != null) { if (ds.Tables[0].Rows[0]["SHORTNAME"].ToString().Trim() != "") { System.Web.UI.ScriptManager.RegisterStartupScript(this.UpdatePanel3, this.GetType(), "unReport30", "alert('客户简称重复,请重新填写!');", true); return; } } // bl = getEdit(); } // if (bl) { Panel1.Visible = false; ibAdd.Enabled = true; ibEnter.Enabled = false; // getDLInfoShipper(); return; } else { System.Web.UI.ScriptManager.RegisterStartupScript(this.UpdatePanel3, this.GetType(), "unReport31", "alert('出错,请重新填写!');", true); return; } } protected void btnAdd_Click(object sender, EventArgs e) { Panel1.Visible = true; ibAdd.Enabled = false; ibEnter.Enabled = true; // ViewState["strHandleType"] = "add"; tbshipperID.Text = ""; tbSHORTNAME.Text = ""; txtshipperdetail.Value = ""; RadioButtonList1.SelectedIndex = 0; cbISPUBLIC.Checked = false; txtloadAddress.Value = ""; txtdeliveraddress.Value = ""; } protected void ibFresh_Click(object sender, ImageClickEventArgs e) { Panel1.Visible = false; ibAdd.Enabled = true; ibEnter.Enabled = false; // getDLInfoShipper(); } public bool IsNumeric(string s) { bool bReturn = true; try { int inum = int.Parse(s); } catch { bReturn = false; } return bReturn; } protected void dlInfoShipper_ItemCommand(object source, DataListCommandEventArgs e) { if (e.CommandName == "ibDel") { string strshipperID = dlInfoShipper.DataKeys[e.Item.ItemIndex].ToString().Trim(); string alt = T_ALL_DA.GetInfoShipperDel(strshipperID, strUserID.Trim()); if (alt != "") { System.Web.UI.ScriptManager.RegisterStartupScript(this.UpdatePanel3, this.GetType(), "unReport50", "alert('" + alt + "');", true); return; } getDLInfoShipper(); } // if (e.CommandName == "ibEdit") { string strshipperID = dlInfoShipper.DataKeys[e.Item.ItemIndex].ToString().Trim(); ViewState["shipperID"] = strshipperID; DataSet ds = T_ALL_DA.GetInfoShipperSQL(" and shipperID='"+strshipperID+"'"); if (ds != null) { if(ds.Tables[0].Rows[0]["shipperID"].ToString().Trim()!="") { Panel1.Visible = true; ibAdd.Enabled = false; ibEnter.Enabled = true; // ViewState["strHandleType"] = "edit"; tbshipperID.Text = ds.Tables[0].Rows[0]["shipperID"].ToString().Trim(); tbSHORTNAME.Text = ds.Tables[0].Rows[0]["SHORTNAME"].ToString().Trim(); txtshipperdetail.Value = ds.Tables[0].Rows[0]["shipperdetail"].ToString().Trim(); RadioButtonList1.SelectedIndex = int.Parse(ds.Tables[0].Rows[0]["shippertype"].ToString().Trim())-1; cbISPUBLIC.Checked = Boolean.Parse(ds.Tables[0].Rows[0]["ISPUBLIC"].ToString().Trim()); txtloadAddress.Value = ds.Tables[0].Rows[0]["LOADADDRESS"].ToString().Trim(); txtdeliveraddress.Value = ds.Tables[0].Rows[0]["DELIVERADDRESS"].ToString().Trim(); } } getDLInfoShipper(); } } } }