Пример #1
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (this.Name.Text == "")
            {
                this.Label2.Text = "请输入材料名";
                return;
            }


            //对Material表的输入
            DateTime begindate = Convert.ToDateTime(this.begindate.Text);
            DateTime enddate   = Convert.ToDateTime(this.enddate.Text);
            string   name      = this.Name.Text.Trim();
            string   address   = this.TextBox_Address.Text.Trim();
            string   number    = this.TextBox_Number.Text.Trim();

            // Maticsoft.Model.W_Material material = new Maticsoft.Model.W_Material();
            Maticsoft.BLL.W_Material bll = new Maticsoft.BLL.W_Material();
            model.Name      = name;
            model.Begindate = begindate;
            model.Enddate   = enddate;
            model.Address   = address;
            model.Number    = number;

            int id;

            Maticsoft.Model.W_Receivestate receivestate = new Maticsoft.Model.W_Receivestate();
            Maticsoft.BLL.W_Receivestate   bllstate     = new Maticsoft.BLL.W_Receivestate();

            if (this.Label_materialId.Text == "")
            {
                                                  //添加
                    id = bll.Add(model);
            }
            else //修改
            {
                id       = int.Parse(this.Label_materialId.Text.Trim());
                model.Id = int.Parse(this.Label_materialId.Text.Trim());
                bll.Update(model);

                //对W_Receivestate表的操作 添加时是否需要 bllstate.delete??
                bllstate.Delete(id);
            }


            receivestate.MaterialId = id;
            for (int i = 0; i < this.CheckBoxList_Reciever.Items.Count; i++)
            {
                if (this.CheckBoxList_Reciever.Items[i].Selected)
                {
                    receivestate.ReceiverId = this.CheckBoxList_Reciever.Items[i].Value;
                    bllstate.Add(receivestate);
                }
            }
            if (id > 1)
            {
                //this.Label_Msg.Text = "提交成功!";
            }
            Response.Redirect("ManagerMaterial.aspx");
        }
Пример #2
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (this.Name.Text == "")
            {
                this.Label2.Text = "请输入材料名";
                return;
            }



            Maticsoft.Model.W_Receivestate receivestate = new Maticsoft.Model.W_Receivestate();
            Maticsoft.BLL.W_Receivestate   bllstate     = new Maticsoft.BLL.W_Receivestate();


            for (int i = 0; i < this.CheckBoxList_Reciever.Items.Count; i++)
            {
                if (this.CheckBoxList_Reciever.Items[i].Selected)
                {
                    receivestate.ReceiverId = this.CheckBoxList_Reciever.Items[i].Value;
                    receivestate.MaterialId = int.Parse(this.Label1.Text.Trim());
                    receivestate.Dormacy    = "提交";
                    receivestate.IssureTime = Convert.ToDateTime(DateTime.Now.ToShortTimeString());
                    bllstate.Update(receivestate);
                }
            }
            if (int.Parse(this.Label1.Text) > 1)
            {
                //this.Label_Msg.Text = "提交成功!";
            }
            Response.Redirect("AllList.aspx");
        }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.W_Receivestate model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into W_Receivestate(");
            strSql.Append("MaterialId,ReceiverId,Dormacy,IssureTime)");
            strSql.Append(" values (");
            strSql.Append("@MaterialId,@ReceiverId,@Dormacy,@IssureTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MaterialId", SqlDbType.Int,       4),
                new SqlParameter("@ReceiverId", SqlDbType.NVarChar, 50),
                new SqlParameter("@Dormacy",    SqlDbType.NVarChar, 50),
                new SqlParameter("@IssureTime", SqlDbType.DateTime)
            };
            parameters[0].Value = model.MaterialId;
            parameters[1].Value = model.ReceiverId;
            parameters[2].Value = model.Dormacy;
            parameters[3].Value = model.IssureTime;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.W_Receivestate GetModel(int MaterialId, string ReceiverId, int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,MaterialId,ReceiverId,Dormacy,IssureTime from W_Receivestate ");
            strSql.Append(" where MaterialId=@MaterialId and ReceiverId=@ReceiverId and Id=@Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MaterialId", SqlDbType.Int,       4),
                new SqlParameter("@ReceiverId", SqlDbType.NVarChar, 50),
                new SqlParameter("@Id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = MaterialId;
            parameters[1].Value = ReceiverId;
            parameters[2].Value = Id;

            Maticsoft.Model.W_Receivestate model = new Maticsoft.Model.W_Receivestate();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MaterialId"].ToString() != "")
                {
                    model.MaterialId = int.Parse(ds.Tables[0].Rows[0]["MaterialId"].ToString());
                }
                model.ReceiverId = ds.Tables[0].Rows[0]["ReceiverId"].ToString();
                model.Dormacy    = ds.Tables[0].Rows[0]["Dormacy"].ToString();
                if (ds.Tables[0].Rows[0]["IssureTime"].ToString() != "")
                {
                    model.IssureTime = DateTime.Parse(ds.Tables[0].Rows[0]["IssureTime"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #5
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (this.Name.Text == "")
            {
                this.Label2.Text = "请输入材料名";
                return;

            }




            Maticsoft.Model.W_Receivestate receivestate = new Maticsoft.Model.W_Receivestate();
            Maticsoft.BLL.W_Receivestate bllstate = new Maticsoft.BLL.W_Receivestate();


            for (int i = 0; i < this.CheckBoxList_Reciever.Items.Count; i++)
            {
                if (this.CheckBoxList_Reciever.Items[i].Selected)
                {
                    receivestate.ReceiverId = this.CheckBoxList_Reciever.Items[i].Value;
                    receivestate.MaterialId = int.Parse(this.Label1.Text.Trim());
                    receivestate.Dormacy = "提交";
                    receivestate.IssureTime = Convert.ToDateTime(DateTime.Now.ToShortTimeString());
                    bllstate.Update(receivestate);





                }
            }
            if (int.Parse(this.Label1.Text) > 1)
            {
                //this.Label_Msg.Text = "提交成功!";
            }
            Response.Redirect("AllList.aspx");
        }
Пример #6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Maticsoft.Model.W_Receivestate model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update W_Receivestate set ");
            strSql.Append("Dormacy=@Dormacy,");
            strSql.Append("IssureTime=@IssureTime");
            strSql.Append(" where MaterialId=@MaterialId and ReceiverId=@ReceiverId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",         SqlDbType.Int,       4),
                new SqlParameter("@MaterialId", SqlDbType.Int,       4),
                new SqlParameter("@ReceiverId", SqlDbType.NVarChar, 50),
                new SqlParameter("@Dormacy",    SqlDbType.NVarChar, 50),
                new SqlParameter("@IssureTime", SqlDbType.DateTime)
            };
            parameters[0].Value = model.Id;
            parameters[1].Value = model.MaterialId;
            parameters[2].Value = model.ReceiverId;
            parameters[3].Value = model.Dormacy;
            parameters[4].Value = model.IssureTime;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Пример #7
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (this.Name.Text == "") 
            { 
                this.Label2.Text = "请输入材料名";
                return;    

            }


            //对Material表的输入
            DateTime begindate = Convert .ToDateTime (this .begindate .Text );
            DateTime enddate = Convert.ToDateTime(this.enddate .Text);
            string name = this.Name .Text.Trim();
            string address = this.TextBox_Address.Text.Trim();
            string number = this.TextBox_Number.Text.Trim();
           // Maticsoft.Model.W_Material material = new Maticsoft.Model.W_Material();
            Maticsoft.BLL.W_Material bll = new Maticsoft.BLL.W_Material();
            model.Name = name;
            model.Begindate = begindate;
            model.Enddate = enddate;
            model.Address = address;
            model.Number = number;

            int id;
            Maticsoft.Model.W_Receivestate receivestate = new Maticsoft.Model.W_Receivestate();
            Maticsoft.BLL.W_Receivestate bllstate = new Maticsoft.BLL.W_Receivestate();
   
            if (this.Label_materialId.Text == "") //添加
                id = bll.Add(model);
            else //修改
            {
                id = int.Parse( this.Label_materialId.Text.Trim());
                model.Id = int.Parse(this.Label_materialId.Text.Trim());
                bll.Update(model);

                //对W_Receivestate表的操作 添加时是否需要 bllstate.delete??
                bllstate.Delete(id);
  
            }

             
            receivestate.MaterialId = id;
            for (int i = 0; i < this.CheckBoxList_Reciever.Items.Count; i++)
            {
                if (this.CheckBoxList_Reciever.Items[i].Selected)
                {
                    receivestate.ReceiverId = this.CheckBoxList_Reciever.Items[i].Value;                    
                        bllstate.Add(receivestate);                   
                }
            }
            if (id > 1)
            {
                //this.Label_Msg.Text = "提交成功!";
            }
            Response.Redirect("ManagerMaterial.aspx");
        }
Пример #8
0
        public Maticsoft.Model.W_Receivestate GetModel(int MaterialId)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 Id,MaterialId,ReceiverId,Dormacy,IssureTime from W_Receivestate ");
            strSql.Append(" where MaterialId=@MaterialId  ");
            SqlParameter[] parameters = {
					new SqlParameter("@MaterialId", SqlDbType.Int,4),
					};
            parameters[0].Value = MaterialId;
            

            Maticsoft.Model.W_Receivestate model = new Maticsoft.Model.W_Receivestate();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MaterialId"].ToString() != "")
                {
                    model.MaterialId = int.Parse(ds.Tables[0].Rows[0]["MaterialId"].ToString());
                }
                model.ReceiverId = ds.Tables[0].Rows[0]["ReceiverId"].ToString();
                model.Dormacy = ds.Tables[0].Rows[0]["Dormacy"].ToString();
                if (ds.Tables[0].Rows[0]["IssureTime"].ToString() != "")
                {
                    model.IssureTime = DateTime.Parse(ds.Tables[0].Rows[0]["IssureTime"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }