Ejemplo n.º 1
0
 public override UsualBookTableModel[] GetChilds(string parentpk, DB_OPT dbo)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("select  ");
     builder.Append(" * ");
     builder.Append(" from " + base.TableName + " ");
     if (parentpk != "")
     {
         builder.Append(" where FatherPK='" + parentpk + "'");
     }
     DataSet set = dbo.BackDataSet(builder.ToString(), null);
     if (set.Tables[0].Rows.Count <= 0)
     {
         return null;
     }
     UsualBookTableModel[] modelArray = new UsualBookTableModel[set.Tables[0].Rows.Count];
     for (int i = 0; i < set.Tables[0].Rows.Count; i++)
     {
         modelArray[i] = new UsualBookTableModel();
         modelArray[i] = this.Getmm(set.Tables[0].Rows[i], true, dbo);
     }
     return modelArray;
 }
Ejemplo n.º 2
0
 public void addupdate()
 {
     try
     {
         this.dbo = new DB_OPT();
         this.dbo.Open();
         if ((this.txtname.Text.Trim() == "") || (this.txtBH.Text.Trim() == ""))
         {
             Const.ShowMessage("带*的数据必须填写!", this.Page);
         }
         else
         {
             this.ubtm = new UsualBookTableDal();
             this.um = new UsualBookTableModel();
             this.ubtm.FatherPK = this.FatherPk.Value.Trim();
             this.ubtm.TableName = base.Request.QueryString["tn"].ToString().Trim();
             if (this.ubtm.FatherPK != "")
             {
                 this.ubtm.PK = this.ubtm.FatherPK.Trim();
                 this.um = this.ubtm.GetModel(false, this.dbo);
                 if (this.um.IsHasBaby == "0")
                 {
                     this.ubtm.TableName = base.Request.QueryString["tn"].ToString();
                     this.ubtm.UpdateHasBaby(this.dbo);
                 }
                 this.ubtm.PKPath = this.ubtm.PKPath + this.ubtm.PK + "|";
                 this.ubtm.Grade = this.um.Grade;
             }
             this.ubtm.BH = this.txtBH.Text.Trim();
             this.ubtm.TableName = base.Request.QueryString["tn"].ToString().Trim();
             this.ubtm.Name = this.txtname.Text.Trim();
             this.ubtm.Discription = this.txtDiscription.Text.Trim();
             this.ubtm.FatherPK = this.FatherPk.Value.Trim();
             this.ubtm.IsHasBaby = "0";
             this.ubtm.Grade++;
             int count = 0;
             if ((base.Request["PK"] != null) && (base.Request["PK"].ToString() != ""))
             {
                 this.ubtm.PK = base.Request["PK"].ToString().Trim();
                 Const.UpdateSuccess(this.ubtm.Update(this.dbo), this.Page);
             }
             else
             {
                 this.ubtm.BH = this.txtBH.Text.Trim();
                 if (this.ubtm.Exists(this.dbo) > 0)
                 {
                     Const.ShowMessage("该编号已经存在!", this.Page);
                 }
                 else
                 {
                     count = this.ubtm.Add(this.dbo);
                     if (base.Request["reload"] != null)
                     {
                         Const.AddSuccess(count, base.Request["reload"].ToString(), this.Page);
                     }
                     else
                     {
                         Const.AddSuccess(count, "", this.Page);
                     }
                 }
             }
         }
     }
     catch (Exception exception)
     {
         this.el = new ExceptionLog.ExceptionLog();
         this.el.ErrClassName = base.GetType().ToString();
         this.el.ErrMessage = exception.Message.ToString();
         this.el.ErrMethod = "addupdate()";
         this.el.WriteExceptionLog(true);
         Const.OpenErrorPage("操作失败,请联系管理员!", this.Page);
     }
     finally
     {
         if (this.dbo != null)
         {
             this.dbo.Close();
         }
     }
 }
Ejemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     string userName = ((UserModel)this.Session["User"]).UserName;
     string power = ((UserModel)this.Session["User"]).Power;
     ButtonsModel model = new ButtonsModel(userName)
     {
         IfAdd = false,
         IfUpdate = false,
         IfDelete = false,
         IfLook = false,
         IfSearch = false,
         IfRefresh = true,
         IfHuiZong = false,
         IfPutOut = false,
         IfSet = false,
         IfExit = true
     };
     this.Master.btModel = model;
     this.Master.ButtonsPushDown = new ButtonsHandler(this.Buttons);
     if (!base.IsPostBack)
     {
         if (this.Session["user"] == null)
         {
             Const.GoLoginPath_OpenWindow(this.Page);
         }
         else
         {
             if ((base.Request["PK"] != null) && (base.Request["PK"].ToString() != ""))
             {
                 model.IfSave = true;
                 this.getTitleUpdate();
                 this.txtBH.ReadOnly = true;
                 this.flog.Value = "Update";
                 try
                 {
                     this.dbo = new DB_OPT();
                     this.dbo.Open();
                     this.ubtm = new UsualBookTableDal();
                     this.ubtm.TableName = base.Request["tn"].ToString();
                     this.ubtm.PK = base.Request["PK"].ToString();
                     this.ubtm = this.ubtm.GetModel(true, this.dbo);
                     this.txtBH.Text = this.ubtm.BH;
                     this.txtname.Text = this.ubtm.Name.ToString();
                     this.txtDiscription.Text = this.ubtm.Discription.ToString();
                     this.FatherPk.Value = this.ubtm.FatherPK.Trim();
                     if (this.ubtm.FatherPK.ToString() != "")
                     {
                         DataSet set = new DataSet();
                         string strSql = "select * from " + base.Request["tn"].ToString() + " where pk='" + this.ubtm.FatherPK.Trim() + "'";
                         set = this.dbo.BackDataSet(strSql, null);
                         if ((set != null) && (set.Tables[0].Rows.Count > 0))
                         {
                             this.txtFatherPk.Text = set.Tables[0].Rows[0]["Name"].ToString();
                         }
                     }
                 }
                 catch (Exception exception)
                 {
                     this.el = new ExceptionLog.ExceptionLog();
                     this.el.ErrClassName = base.GetType().ToString();
                     this.el.ErrMessage = exception.Message.ToString();
                     this.el.ErrMethod = "addupdate()";
                     this.el.WriteExceptionLog(true);
                     Const.OpenErrorPage("获取数据失败,请联系管理员!", this.Page);
                 }
                 finally
                 {
                     if (this.dbo != null)
                     {
                         this.dbo.Close();
                     }
                 }
             }
             else
             {
                 model.IfSave = true;
                 this.getTitleAdd();
                 this.flog.Value = "add";
             }
             if (base.Request["tn"] != null)
             {
                 this.tableName.Value = base.Request["tn"].ToString();
             }
         }
     }
 }
Ejemplo n.º 4
0
 public bool checkUsualBookTable(string strWhere, string tableName)
 {
     this.um = new UsualBookTableDal();
     this.dbo = new DB_OPT();
     this.um.TableName = tableName;
     return (this.um.GetList(strWhere, this.dbo).Tables[0].Rows.Count > 0);
 }
Ejemplo n.º 5
0
 protected void SearchControl(object sender, string strselect, string strcloname, string strsql, DataSet dstable, DataSet dsclo)
 {
     this.ubtm = new UsualBookTableDal();
     if (base.Request.QueryString["tn"].ToString() != "")
     {
         this.ubtm.TableName = base.Request.QueryString["tn"].ToString();
     }
     PageUsuClass.SearchControl(strselect, strcloname, strsql, this.pageind, this.ubtm.TableName + "DictionaryStep", this.Page);
 }
Ejemplo n.º 6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (base.Request["strTitle"] != null)
     {
         this.txttitle.Value = base.Server.UrlDecode(base.Request["strTitle"].ToString().Trim());
     }
     this.Master.strTitle = this.txttitle.Value;
     this.Master.ButtonsPushDown = new ButtonsHandler(this.Buttons);
     this.Master.SearchHasGone = new SearchHandler(this.SearchControl);
     this.Master.PageNavigatorChange = new PageNavigatorHandler(this.PageChangControl);
     if (!base.IsPostBack)
     {
         if (this.Session["user"] == null)
         {
             Const.GoLoginPath_List(this.Page);
         }
         else
         {
             string userName = ((UserModel)this.Session["User"]).UserName;
             string power = ((UserModel)this.Session["User"]).Power;
             ButtonsModel model = new ButtonsModel(userName);
             if (userName == "admin")
             {
                 model.IfAdd = true;
                 model.IfUpdate = true;
                 model.IfDelete = true;
                 model.IfLook = false;
                 model.IfSearch = false;
                 model.IfRefresh = true;
                 model.IfHuiZong = false;
                 model.IfPutOut = false;
                 model.IfSet = false;
                 model.IfExit = true;
             }
             else if ((((base.Request["List"] != null) && (base.Request["Add"] != null)) && ((base.Request["Update"] != null) && (base.Request["Delete"] != null))) && (base.Request["Print"] != null))
             {
                 if (PowerClass.IfHasPower(userName, power, base.Request["List"].ToString()))
                 {
                     if (PowerClass.IfHasPower(userName, power, base.Request["Add"].ToString()))
                     {
                         model.IfAdd = true;
                     }
                     if (PowerClass.IfHasPower(userName, power, base.Request["Update"].ToString()))
                     {
                         model.IfUpdate = true;
                     }
                     if (PowerClass.IfHasPower(userName, power, base.Request["Delete"].ToString()))
                     {
                         model.IfDelete = true;
                     }
                 }
                 else
                 {
                     Const.SorryForPower_List(this.Page);
                 }
             }
             this.Master.btModel = model;
             this.ubtm = new UsualBookTableDal();
             if (base.Request.QueryString["tn"].ToString() != "")
             {
                 this.ubtm.TableName = base.Request.QueryString["tn"].ToString();
             }
             string[] names = new string[] { "Name", "BH" };
             DataSet searchControlDataSet = Common.GetSearchControlDataSet(names);
             this.Master.DataSetClo = searchControlDataSet;
             names[0] = "名称";
             names[1] = "编号";
             DataSet set2 = Common.GetSearchControlDataSet(names);
             this.Master.DataSetTable = set2;
         }
     }
 }
Ejemplo n.º 7
0
 protected void PageChangControl(object sender, int nPageIndex)
 {
     this.ubtm = new UsualBookTableDal();
     if (base.Request.QueryString["tn"].ToString() != "")
     {
         this.ubtm.TableName = base.Request.QueryString["tn"].ToString();
     }
     PageUsuClass.PageChangControl(nPageIndex, this.ubtm.TableName + "DictionaryStep", this.Page);
 }
Ejemplo n.º 8
0
 public void ShowData(string str)
 {
     try
     {
         this.dbo = new DB_OPT();
         this.ubtm = new UsualBookTableDal();
         this.dbo.Open();
         if ((base.Request.QueryString["tn"] != null) && (base.Request.QueryString["tn"] != ""))
         {
             this.ubtm.TableName = base.Request.QueryString["tn"].ToString();
             if ((str != "") && (str != null))
             {
                 str = " where " + str + " ";
             }
             DataSet set = this.pagesize.pagesize("*", this.ubtm.TableName, str, "PK", "", this.Master.PageIndex, this.Master.PageSize, out this.count);
             this.Master.RecordCount = Convert.ToInt32(this.count);
             if ((set != null) && (set.Tables[0].Rows.Count > 0))
             {
                 set.Tables[0].Columns.Add(new DataColumn("FatherName", Type.GetType("System.String")));
                 DataSet list = new DataSet();
                 list = this.ubtm.GetList("", this.dbo);
                 foreach (DataRow row in set.Tables[0].Rows)
                 {
                     if ((row["FatherPK"].ToString().Trim() == "0") || (row["FatherPK"].ToString() == ""))
                     {
                         row["FatherName"] = "无";
                     }
                     else
                     {
                         DataRow[] rowArray = list.Tables[0].Select("PK='" + row["FatherPK"].ToString().Trim() + "'");
                         if ((rowArray != null) && (rowArray.Length > 0))
                         {
                             row["FatherName"] = rowArray[0]["Name"];
                         }
                     }
                 }
                 DataView defaultView = set.Tables[0].DefaultView;
                 if ((this.ViewState["SortOrder"] != null) && (this.ViewState["OrderDire"] != null))
                 {
                     string str2 = ((string)this.ViewState["SortOrder"]) + " " + ((string)this.ViewState["OrderDire"]);
                     defaultView.Sort = str2;
                 }
                 this.gvResult.DataSource = defaultView;
                 this.gvResult.DataBind();
             }
             else
             {
                 DataTable table = new DataTable();
                 table = set.Tables[0];
                 set.Tables[0].Columns.Add(new DataColumn("FatherName", Type.GetType("System.String")));
                 foreach (DataRow row2 in set.Tables[0].Rows)
                 {
                     row2["FatherName"] = "无";
                 }
                 DataRow row3 = table.NewRow();
                 table.Rows.Add(row3);
                 this.gvResult.DataSource = table.DefaultView;
                 this.gvResult.DataBind();
             }
         }
     }
     catch (Exception exception)
     {
         this.el = new ExceptionLog.ExceptionLog();
         this.el.ErrClassName = base.GetType().ToString();
         this.el.ErrMessage = exception.Message.ToString();
         this.el.ErrMethod = "ShowData()";
         this.el.WriteExceptionLog(true);
         Const.OpenErrorPage("获取数据失败,请联系系统管理员!", this.Page);
     }
     finally
     {
         if (this.dbo != null)
         {
             this.dbo.Close();
         }
     }
 }
Ejemplo n.º 9
0
 public void delete()
 {
     if ((this.gvResult.SelectedIndex >= 0) && (this.gvResult.Rows.Count >= this.gvResult.SelectedIndex))
     {
         try
         {
             try
             {
                 this.dbo = new DB_OPT();
                 this.ubtm = new UsualBookTableDal();
                 this.dbo.Open();
                 this.ubtm.TableName = base.Request.QueryString["tn"].ToString();
                 this.ubtm.PK = ((TextBox)this.gvResult.Rows[this.gvResult.SelectedIndex].Cells[0].FindControl("txtPK")).Text;
                 this.ubtm.Delete(this.dbo);
             }
             catch (Exception exception)
             {
                 this.el = new ExceptionLog.ExceptionLog();
                 this.el.ErrClassName = base.GetType().ToString();
                 this.el.ErrMessage = exception.Message.ToString();
                 this.el.ErrMethod = "delete()";
                 this.el.WriteExceptionLog(true);
                 Const.OpenErrorPage("操作失败,请联系系统管理员!", this.Page);
             }
             return;
         }
         finally
         {
             if (this.dbo != null)
             {
                 this.dbo.Close();
             }
         }
     }
     PageShowText.ShowMessage_List("请先选择一行再删除!", this.Page);
 }
Ejemplo n.º 10
0
 public override UsualBookTableModel[] GetEgality(bool bj, DB_OPT dbo)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("select  ");
     builder.Append(" * ");
     builder.Append(" from " + base.TableName + " ");
     if (base.Grade >= 0)
     {
         builder.Append(" where Grade='" + base.Grade + "'");
     }
     else
     {
         if (base.PK == "")
         {
             throw new Exception("条件不足.");
         }
         builder.Append(" where Grade=(select Grade from " + base.TableName + " where PK='" + base.PK + "')");
     }
     DataSet set = dbo.BackDataSet(builder.ToString(), null);
     if (set.Tables[0].Rows.Count <= 0)
     {
         return null;
     }
     UsualBookTableModel[] modelArray = new UsualBookTableModel[set.Tables[0].Rows.Count];
     for (int i = 0; i < set.Tables[0].Rows.Count; i++)
     {
         modelArray[i] = new UsualBookTableModel();
         modelArray[i] = this.Getmm(set.Tables[0].Rows[i], bj, dbo);
     }
     return modelArray;
 }
Ejemplo n.º 11
0
 private UsualBookTableModel Getmm(DataRow dr, bool bj, DB_OPT dbo)
 {
     UsualBookTableModel model = new UsualBookTableModel {
         PK = dr["PK"].ToString(),
         Name = dr["Name"].ToString(),
         Discription = dr["Discription"].ToString(),
         FatherPK = dr["FatherPK"].ToString(),
         IsHasBaby = dr["IsHasBaby"].ToString(),
         BH = dr["BH"].ToString()
     };
     if (dr["Grade"].ToString() != "")
     {
         model.Grade = int.Parse(dr["Grade"].ToString());
     }
     model.PKPath = dr["PKPath"].ToString();
     if ((dr["IsHasBaby"].ToString() == "1") && bj)
     {
         model.ubtm = this.GetChilds(model.PK, dbo);
     }
     return model;
 }
Ejemplo n.º 12
0
 public override UsualBookTableModel[] GetParents(DB_OPT dbo)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("select  ");
     builder.Append(" * ");
     builder.Append(" from " + base.TableName + " ");
     if (base.PKPath != "")
     {
         string[] strArray = base.PKPath.Split(new char[] { '|' });
         string str = "";
         for (int j = 0; j < strArray.Length; j++)
         {
             if (strArray[j] != "")
             {
                 str = str + "'" + strArray[j] + "',";
             }
         }
         builder.Append(" where PK in (" + str.Substring(0, str.Length - 1) + ")");
     }
     else
     {
         if (!(base.PK != ""))
         {
             return null;
         }
         string strSql = "select PKPath from " + base.TableName + " where PK='" + base.PK + "'";
         DataSet set = dbo.BackDataSet(strSql, null);
         if (set.Tables[0].Rows[0][0].ToString() != "")
         {
             string[] strArray2 = set.Tables[0].Rows[0][0].ToString().Split(new char[] { '|' });
             string str3 = "";
             for (int k = 0; k < strArray2.Length; k++)
             {
                 if (strArray2[k] != "")
                 {
                     str3 = str3 + "'" + strArray2[k] + "',";
                 }
             }
             builder.Append(" where PK in (" + str3.Substring(0, str3.Length - 1) + ")");
         }
         else
         {
             builder.Append(" where PK='" + base.PK + "'");
         }
     }
     DataSet set2 = dbo.BackDataSet(builder.ToString(), null);
     if (set2.Tables[0].Rows.Count <= 0)
     {
         return null;
     }
     UsualBookTableModel[] modelArray = new UsualBookTableModel[set2.Tables[0].Rows.Count];
     for (int i = 0; i < set2.Tables[0].Rows.Count; i++)
     {
         modelArray[i] = new UsualBookTableModel();
         modelArray[i] = this.Getmm(set2.Tables[0].Rows[i], false, dbo);
     }
     return modelArray;
 }
Ejemplo n.º 13
0
 public override UsualBookTableModel[] GetModels(string strwhere, bool bj, DB_OPT dbo)
 {
     UsualBookTableModel[] modelArray = null;
     StringBuilder builder = new StringBuilder();
     builder.Append("select ");
     builder.Append(" * ");
     builder.Append(" from " + base.TableName + " ");
     if (strwhere.Trim() != "")
     {
         builder.Append(" where " + strwhere);
     }
     DataSet set = dbo.BackDataSet(builder.ToString(), null);
     if (set.Tables[0].Rows.Count > 0)
     {
         modelArray = new UsualBookTableModel[set.Tables[0].Rows.Count];
         for (int i = 0; i < set.Tables[0].Rows.Count; i++)
         {
             modelArray[i] = new UsualBookTableModel();
             modelArray[i] = this.Getmm(set.Tables[0].Rows[i], bj, dbo);
         }
     }
     return modelArray;
 }