Ejemplo n.º 1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <System.Model.repairs> DataTableToList(DataTable dt)
        {
            List <System.Model.repairs> modelList = new List <System.Model.repairs>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                System.Model.repairs model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new System.Model.repairs();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    model.facility = dt.Rows[n]["facility"].ToString();
                    model.customId = dt.Rows[n]["customId"].ToString();
                    model.cause    = dt.Rows[n]["cause"].ToString();
                    if (dt.Rows[n]["pudate"].ToString() != "")
                    {
                        model.pudate = DateTime.Parse(dt.Rows[n]["pudate"].ToString());
                    }
                    model.toid = dt.Rows[n]["toid"].ToString();
                    if (dt.Rows[n]["types"].ToString() != "")
                    {
                        model.types = int.Parse(dt.Rows[n]["types"].ToString());
                    }


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                main_menu.menu1 = "6";
                main_menu.menu2 = "6";

                if (RolePermissions("6001") == false)
                {
                    Response.Write("<script language='javascript'>window.location.href='errorQx.aspx?menu1=2&menu2=4';</script>");
                }
                else
                {
                    string id = Request["id"] != null?Utility.Helper.Checkstr(Request["id"]) : "";


                    System.Model.repairs sq = _bll.rebll.GetModel(Utility.Helper.gerInt(id));

                    if (sq != null)
                    {
                        member_p.InnerText = sq.customId;

                        type_p.InnerText   = getRepairsType(Utility.Helper.gerString(sq.types));
                        cause_p.InnerText  = sq.cause;
                        pudate_p.InnerText = sq.pudate.ToString();


                        string strwhere = "  guishu='" + sq.toid + "'  ";

                        List <System.Model.repairs_img> cr = _bll.reibll.GetModelList(strwhere);


                        StringBuilder strHtml = new StringBuilder();

                        if (cr.Count > 0)
                        {
                            for (int i = 0; i < cr.Count; i++)
                            {
                                strHtml.Append("<a class='addsed' href='" + cr[i].img + "'><img src='" + cr[i].img + "' alt=''></a>");
                            }

                            ziyuane_p.InnerHtml = strHtml.ToString();
                        }
                    }
                    else
                    {
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public System.Model.repairs GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id, facility, customId, cause, pudate, toid, types  ");
            strSql.Append("  from repairs ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;


            System.Model.repairs model = new System.Model.repairs();
            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());
                }
                model.facility = ds.Tables[0].Rows[0]["facility"].ToString();
                model.customId = ds.Tables[0].Rows[0]["customId"].ToString();
                model.cause    = ds.Tables[0].Rows[0]["cause"].ToString();
                if (ds.Tables[0].Rows[0]["pudate"].ToString() != "")
                {
                    model.pudate = DateTime.Parse(ds.Tables[0].Rows[0]["pudate"].ToString());
                }
                model.toid = ds.Tables[0].Rows[0]["toid"].ToString();
                if (ds.Tables[0].Rows[0]["types"].ToString() != "")
                {
                    model.types = int.Parse(ds.Tables[0].Rows[0]["types"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(System.Model.repairs model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update repairs set ");

            strSql.Append(" facility = @facility , ");
            strSql.Append(" customId = @customId , ");
            strSql.Append(" cause = @cause , ");
            strSql.Append(" pudate = @pudate , ");
            strSql.Append(" toid = @toid , ");
            strSql.Append(" types = @types  ");
            strSql.Append(" where id=@id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@id",       SqlDbType.Int,         4),
                new SqlParameter("@facility", SqlDbType.NVarChar,   50),
                new SqlParameter("@customId", SqlDbType.NVarChar,   50),
                new SqlParameter("@cause",    SqlDbType.NVarChar,  200),
                new SqlParameter("@pudate",   SqlDbType.DateTime),
                new SqlParameter("@toid",     SqlDbType.NVarChar,   50),
                new SqlParameter("@types",    SqlDbType.Int, 4)
            };

            parameters[0].Value = model.id;
            parameters[1].Value = model.facility;
            parameters[2].Value = model.customId;
            parameters[3].Value = model.cause;
            parameters[4].Value = model.pudate;
            parameters[5].Value = model.toid;
            parameters[6].Value = model.types;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(System.Model.repairs model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into repairs(");
            strSql.Append("facility,customId,cause,pudate,toid,types");
            strSql.Append(") values (");
            strSql.Append("@facility,@customId,@cause,@pudate,@toid,@types");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@facility", SqlDbType.NVarChar,   50),
                new SqlParameter("@customId", SqlDbType.NVarChar,   50),
                new SqlParameter("@cause",    SqlDbType.NVarChar,  200),
                new SqlParameter("@pudate",   SqlDbType.DateTime),
                new SqlParameter("@toid",     SqlDbType.NVarChar,   50),
                new SqlParameter("@types",    SqlDbType.Int, 4)
            };

            parameters[0].Value = model.facility;
            parameters[1].Value = model.customId;
            parameters[2].Value = model.cause;
            parameters[3].Value = model.pudate;
            parameters[4].Value = model.toid;
            parameters[5].Value = model.types;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string   res        = "";
                JsonData jsonResult = new JsonData();
                try
                {
                    //设备编号
                    //string facility = Request["facility"] != null ? Utility.Helper.Checkstr(Request["facility"]) : "";
                    //用户编号
                    string customId = _bll.getUserToke(Utility.Helper.gerString(Request["memberid"]));
                    //原因
                    string cause = Request["cause"] != null?Utility.Helper.Checkstr(Request["cause"]) : "";

                    //报修类型
                    string type = Request["type"] != null?Utility.Helper.Checkstr(Request["type"]) : "";


                    #region 报修设备
                    if (!string.IsNullOrEmpty(customId) && !string.IsNullOrEmpty(cause))
                    {
                        string toid = System.Guid.NewGuid().ToString();


                        System.Model.repairs rp = new System.Model.repairs();

                        rp.cause    = cause;
                        rp.customId = customId;
                        //rp.facility = facility;
                        rp.pudate = System.DateTime.Now;
                        rp.toid   = toid;
                        rp.types  = Utility.Helper.gerInt(type);
                        if (_bll.rebll.Add(rp) > 0)
                        {
                            #region 判断是否有图

                            List <FileInfos> fio = UploadFile(Request, "/Upload/", "repairs/");


                            if (fio.Count > 0)
                            {
                                for (int i = 0; i < fio.Count; i++)
                                {
                                    FileInfos fs = fio[i];
                                    System.Model.repairs_img ri = new System.Model.repairs_img();
                                    ri.img      = fs.datafilename;
                                    ri.pudate   = System.DateTime.Now;
                                    ri.uploader = customId;
                                    ri.guishu   = toid;
                                    _bll.reibll.Add(ri);
                                }
                            }

                            #endregion
                        }
                        jsonResult["res"]  = (int)MyEnum.ResultEnum.成功;
                        jsonResult["msg"]  = "报修成功";
                        jsonResult["code"] = "";
                    }
                    else
                    {
                        jsonResult["res"]  = (int)MyEnum.ResultEnum.失败;
                        jsonResult["msg"]  = "报修失败";
                        jsonResult["code"] = "参数有误";
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    jsonResult["res"]  = (int)MyEnum.ResultEnum.系统错误;
                    jsonResult["msg"]  = "服务器繁忙,请稍后再试";
                    jsonResult["code"] = ex.Message;
                }
                res = JsonMapper.ToJson(jsonResult);
                res = MyString.UnicodeToString(res);
                Response.Write(res);
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(System.Model.repairs model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(System.Model.repairs model)
 {
     return(dal.Add(model));
 }