public SchoolX_资产转移流程表 获取资产转移信息(int id)
        {
            string          sql   = string.Format("SELECT * FROM X_资产转移流程表 WHERE ID=" + id);
            SchoolX_资产转移流程表 model = new SchoolX_资产转移流程表();
            SqlDataReader   read  = DBHelper.ExecuteReader(DBHelper.ConnectionString, CommandType.Text, sql.ToString());

            if (read.Read())
            {
                model.流程状态 = read["流程状态"].ToString();
                model.单据编号 = read["单据编号"].ToString();
                model.事项名称 = read["事项名称"].ToString();
                model.申请人  = read["申请人"].ToString();
                model.申请日期 = read["申请日期"].ToString();
                model.联系方式 = read["联系方式"].ToString();
            }
            return(model);
        }
        public int upzczy(SchoolX_资产转移流程表 model, List <int> listid, List <SchoolX_资产转移改动信息表> listmodel, AM_提醒通知 ammodel, AM_待办业务 dbmodel)
        {
            try
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("INSERT INTO X_资产转移流程表 ");
                sb.Append(" (流程状态,单据编号,事项名称,申请人,申请日期,联系方式,存放地点变更为,归属部门变更为,负责人变更为,备注信息,S_ID,总数,总价,Sort ");
                sb.Append(" ) VALUES( ");
                sb.Append(" @流程状态,@单据编号,@事项名称,@申请人,@申请日期,@联系方式,@存放地点变更为,@归属部门变更为,@负责人变更为,@备注信息,@S_ID,@总数,@总价," + 1);
                sb.Append(")");
                sb.Append(" SELECT ");
                sb.Append(" @@identity ");
                SqlParameter[] para =
                {
                    new SqlParameter("@流程状态",    model.流程状态),
                    new SqlParameter("@单据编号",    model.单据编号),
                    new SqlParameter("@事项名称",    model.事项名称),
                    new SqlParameter("@申请人",     model.申请人),
                    new SqlParameter("@申请日期",    model.申请日期),
                    new SqlParameter("@联系方式",    model.联系方式),
                    new SqlParameter("@存放地点变更为", model.存放地点变更为),
                    new SqlParameter("@归属部门变更为", model.归属部门变更为),
                    new SqlParameter("@负责人变更为",  model.负责人变更为),
                    new SqlParameter("@备注信息",    model.备注信息),
                    new SqlParameter("@S_ID",    model.S_ID),
                    new SqlParameter("@总数",      model.总数),
                    new SqlParameter("@总价",      model.总价),
                };


                int num = Convert.ToInt32(DBHelper.ExecuteScalar(DBHelper.ConnectionString, CommandType.Text, sb.ToString(), para));

                StringBuilder sbtz = new StringBuilder();
                sbtz.Append("INSERT INTO AM_提醒通知 ");
                sbtz.Append("(消息事项,消息内容,发起人,发起时间,通知类型,是否已读,通知职务,FlowID ");
                sbtz.Append(" ) VALUES( ");
                sbtz.Append(" @消息事项,@消息内容,@发起人,@发起时间,@通知类型,@是否已读,@通知职务,@FlowID ");
                sbtz.Append(")");
                SqlParameter[] paratz =
                {
                    new SqlParameter("@消息事项",   ammodel.消息事项),
                    new SqlParameter("@消息内容",   ammodel.消息内容),
                    new SqlParameter("@发起人",    ammodel.发起人),
                    new SqlParameter("@发起时间",   ammodel.发起时间),
                    new SqlParameter("@通知类型",   ammodel.通知类型),
                    new SqlParameter("@是否已读",   ammodel.是否已读),
                    new SqlParameter("@通知职务",   ammodel.通知职务),
                    new SqlParameter("@FlowID", num)
                };
                DBHelper.ExecuteScalar(DBHelper.ConnectionString, CommandType.Text, sbtz.ToString(), paratz);

                //DBHelper.ExecuteScalar(DBHelper.ConnectionString, CommandType.Text, sbtz.ToString(), paratz);
                StringBuilder dbsb = new StringBuilder();
                dbsb.Append("INSERT INTO AM_待办业务 ");
                dbsb.Append("(流程状态,FlowID,处理方式,通知内容,发起人,发起时间,FlowName,处理职务,Sort,事项名称 ");
                dbsb.Append(" ) VALUES( ");
                dbsb.Append(" @流程状态,@FlowID,@处理方式,@通知内容,@发起人,@发起时间,@FlowName,@处理职务,@Sort,@事项名称 ");
                dbsb.Append(")");
                SqlParameter[] dbpara =
                {
                    new SqlParameter("@流程状态",     dbmodel.流程状态),
                    new SqlParameter("@FlowID",   num),
                    new SqlParameter("@处理方式",     dbmodel.处理方式),
                    new SqlParameter("@通知内容",     dbmodel.通知内容),
                    new SqlParameter("@发起人",      dbmodel.发起人),
                    new SqlParameter("@发起时间",     dbmodel.发起时间),
                    new SqlParameter("@处理职务",     dbmodel.处理职务),
                    new SqlParameter("@Sort",     dbmodel.Sort),
                    new SqlParameter("@事项名称",     dbmodel.事项名称),
                    new SqlParameter("@FlowName", dbmodel.FlowName)
                };
                DBHelper.ExecuteScalar(DBHelper.ConnectionString, CommandType.Text, dbsb.ToString(), dbpara);

                List <string> strlist = new List <string>();
                string        sqlzy   = "";
                for (int i = 0; i < listmodel.Count; i++)
                {
                    sqlzy = string.Format("INSERT INTO  [X_资产转移改动信息表] ([转移流程表ID],[办公设备信息表ID],[原存放地点],[原归属部门],[原负责人],[现存放地点],[现归属部门],[现负责人]) VALUES ({0},{1},'{2}','{3}','{4}','{5}','{6}','{7}')", num, listid[i], listmodel[i].原存放地点, listmodel[i].原归属部门, listmodel[i].原负责人, model.存放地点变更为, model.归属部门变更为, model.负责人变更为);
                    strlist.Add(sqlzy);
                }
                int XX = DBHelper.ExecuteSqlTran(strlist);
                //int AA = XX;


                return(XX);

                //if (num > 0)
                //{
                //    int upgsbm = 0;
                //    int upcfdd = 0;
                //    int upfzr = 0;
                //    string sql = string.Format("SELECT ID FROM dbo.一级部门表 where 名称='{0}'", model.归属部门变更为);
                //    SqlDataReader read = DBHelper.ExecuteReader(DBHelper.ConnectionString, CommandType.Text, sql.ToString());
                //    while (read.Read())
                //    {
                //        upgsbm = Convert.ToInt32(read["ID"]);
                //    }
                //    read.Close();


                //    string sqlup2 = string.Format("SELECT   *  from dbo.房间信息表 where 名称 =  '{0}'", model.存放地点变更为);
                //    SqlDataReader readup2 = DBHelper.ExecuteReader(DBHelper.ConnectionString, CommandType.Text, sqlup2.ToString());
                //    while (readup2.Read())
                //    {
                //        upcfdd = Convert.ToInt32(readup2["ID"]);
                //    }
                //    readup2.Close();


                //    string sqlup3 = string.Format("SELECT * FROM 用户表  where 姓名 =  '{0}'", model.负责人变更为);
                //    SqlDataReader readup3 = DBHelper.ExecuteReader(DBHelper.ConnectionString, CommandType.Text, sqlup3.ToString());
                //    while (readup3.Read())
                //    {
                //        upfzr = Convert.ToInt32(readup3["ID"]);
                //    }
                //    readup3.Close();
                //    List<string> cstrlist = new List<string>();
                //    string csqls = "";
                //    for (int i = 0; i < listid.Count; i++)
                //    {
                //        csqls = string.Format("   UPDATE 办公设备信息表 SET 归属部门 = {0} ,位置 = {1}, 归属教师ID = {2} where ID = {3}", upgsbm, upcfdd, upfzr, listid[i]);
                //        cstrlist.Add(csqls.ToString());
                //    }


                //    return DBHelper.ExecuteSqlTran(cstrlist);



                //}
                //else
                //{
                //    return 0;
                //}
            }
            catch (Exception)
            {
                return(0);
                //throw;
            }

            //return sql.upzczy(model, listid);
        }
Esempio n. 3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            //获取原存放地

            string     sid    = "";
            List <int> inlist = new List <int>();
            int        总数     = 0;
            int        总价     = 0;

            //获取grid3选中行数据
            int[] selections = Grid3.SelectedRowIndexArray;
            List <SchoolX_资产转移改动信息表> listmodel = new List <SchoolX_资产转移改动信息表>();

            foreach (int rowIndex in selections)
            {
                SchoolX_资产转移改动信息表 modelx = new SchoolX_资产转移改动信息表();
                int ID = Convert.ToInt32(Grid3.DataKeys[rowIndex][0]);

                modelx.原存放地点 = Grid3.DataKeys[rowIndex][1].ToString();
                modelx.原归属部门 = Grid3.DataKeys[rowIndex][2].ToString();
                modelx.原负责人  = Grid3.DataKeys[rowIndex][3].ToString();

                sid += ID.ToString() + ",";
                inlist.Add(ID);
                listmodel.Add(modelx);
                //sb.AppendFormat("行号:{0} 用户名:{1}<br />", rowIndex + 1, Grid1.DataKeys[rowIndex][1]);
            }

            List <School办公设备信息表> listdata = bll.资产转移确定设备(inlist);

            foreach (School办公设备信息表 itemjj in listdata)
            {
                总数 += itemjj.数量;
                总价 += Convert.ToInt32(itemjj.价格);
            }
            SchoolX_资产转移流程表 model = new SchoolX_资产转移流程表();

            model.流程状态    = 流程状态.Text;
            model.单据编号    = 单据编号.Text;
            model.事项名称    = 事项名称.Text;
            model.申请人     = 申请人.Text;
            model.申请日期    = 申请日期.Text;
            model.联系方式    = 联系方式.Text;
            model.存放地点变更为 = 存放地点变更为.SelectedItem.Text;
            model.归属部门变更为 = 归属部门变更为.SelectedItem.Text;
            model.负责人变更为  = 负责人变更为.SelectedItem.Text;
            model.备注信息    = 备注.Text;
            model.S_ID    = sid;
            model.总数      = 总数;
            model.总价      = 总价;
            AM_提醒通知 ammodel = new AM_提醒通知();

            ammodel.发起时间 = DateTime.Now;
            ammodel.是否已读 = "否";
            ammodel.通知类型 = "待办事项通知";
            ammodel.通知职务 = "资产管理员";
            ammodel.发起人  = model.申请人;
            ammodel.消息内容 = "您来自" + ammodel.发起人 + "的资产交接申请,请及时处理!";
            ammodel.消息事项 = "资产转移";
            ammodel.是否已读 = "否";
            AM_待办业务 dbmodel = new AM_待办业务();

            dbmodel.处理方式     = "职务";
            dbmodel.处理职务     = "资产管理员";
            dbmodel.流程状态     = 流程状态.Text;
            dbmodel.事项名称     = model.事项名称;
            dbmodel.FlowName = "资产转移";
            dbmodel.发起人      = model.申请人;
            dbmodel.通知内容     = "您来自" + dbmodel.发起人 + "的资产交接申请,请及时处理!";
            dbmodel.发起时间     = DateTime.Now.ToLongDateString();
            dbmodel.Sort     = 1;

            if (model.存放地点变更为 == "" || model.存放地点变更为 == null || model.归属部门变更为 == "" || model.归属部门变更为 == null || model.负责人变更为 == "" || model.负责人变更为 == "请选择")
            {
                Alert.ShowInTop("请将信息填写完整!", "提示信息", MessageBoxIcon.Warning);
                return;
            }
            else
            {
                int result = bll.upzczy(model, inlist, listmodel, ammodel, dbmodel);
                if (result > 0)
                {
                    Alert.ShowInTop("提交成功!", "提示信息", MessageBoxIcon.Information);
                    Window1.Hidden = true;
                    DataSet   ds     = bll.首页_X_资产转移流程表("流程状态-全部");
                    DataTable dt     = ds.Tables[0].Copy();//复制一份table
                    DataTable source = dt;

                    // 3.绑定到Grid
                    Grid1.DataSource = dt;//DataTable
                    Grid1.DataBind();

                    return;
                }
            }
        }
 public int upzczy(SchoolX_资产转移流程表 model, List <int> listid, List <SchoolX_资产转移改动信息表> listmodel, AM_提醒通知 ammodel, AM_待办业务 dbmodel)
 {
     return(sql.upzczy(model, listid, listmodel, ammodel, dbmodel));
 }