Example #1
0
        public int UpdateConfig(WEB_CUSTOMSCOST en)
        {
            string sqlStr = @"update WEB_CUSTOMSCOST  set Busitypecode='{0}',Busitypename='{1}',Busiitemcode='{2}',Busiitemname='{3}',Originname='{4}',Configname='{5}',Createuserid='{6}',Createusername='******' where id='{8}'";

            sqlStr = string.Format(sqlStr, en.BUSITYPECODE, en.BUSITYPENAME, en.BUSIITEMCODE, en.BUSIITEMNAME, en.ORIGINNAME, en.CONFIGNAME, en.CREATEUSERID, en.CREATEUSERNAME, en.ID);
            int i = DBMgr.ExecuteNonQuery(sqlStr);

            return(i);
        }
Example #2
0
        /// <summary>
        /// 新增一笔记录
        /// </summary>
        /// <param name="en"></param>
        /// <returns></returns>
        public int AddConfig(WEB_CUSTOMSCOST en)
        {
            string sqlStr = @"insert into WEB_CUSTOMSCOST (Id,Busitypecode,Busitypename,Busiitemcode,Busiitemname,Originname,Configname,Createuserid,Createusername)
                                         values(web_customsconfig_id.nextval,'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')";

            sqlStr = string.Format(sqlStr, en.BUSITYPECODE, en.BUSITYPENAME, en.BUSIITEMCODE, en.BUSIITEMNAME, en.ORIGINNAME, en.CONFIGNAME, en.CREATEUSERID, en.CREATEUSERNAME);
            int i = DBMgr.ExecuteNonQuery(sqlStr);

            return(i);
        }
Example #3
0
        public string CanUpdateOrInsert(WEB_CUSTOMSCOST en)
        {
            string repeat   = "";
            string strWhere = "";

            if (en.ID > 0)
            {
                strWhere = " and t1.id not in ('" + en.ID + "') ";
            }
            string sqlStr = "select * from WEB_CUSTOMSCOST t1 where t1.BUSITYPECODE='{0}' and t1.BUSIITEMCODE='{1}' and t1.ORIGINNAME='{2}' " + strWhere;

            sqlStr = string.Format(sqlStr, en.BUSITYPECODE, en.BUSIITEMCODE, en.ORIGINNAME);
            DataTable dt = DBMgr.GetDataTable(sqlStr);

            if (dt != null && dt.Rows.Count > 0)
            {
                repeat += "不能重复";
            }
            return(repeat);
        }
Example #4
0
        /// <summary>
        /// 保存或更新数据
        /// </summary>
        /// <param name="formdata"></param>
        public void save(string formdata)
        {
            string          response = "";
            string          repeat   = "";
            JObject         json     = (JObject)JsonConvert.DeserializeObject(formdata);
            WEB_CUSTOMSCOST en       = JsonToEntity(json);

            if (en == null)
            {
                repeat = "保存失败,JSON数据转换出现问题";
            }
            else if (en.ID < 0)
            {
                //新增
                repeat = CanUpdateOrInsert(en);
                if (string.IsNullOrEmpty(repeat))
                {
                    int i = AddConfig(en);
                    if (i > 0)
                    {
                        repeat = "5";//代表成功
                    }
                }
            }
            else
            {
                //更新
                repeat = CanUpdateOrInsert(en);
                if (string.IsNullOrEmpty(repeat))
                {
                    int i = UpdateConfig(en);
                    if (i > 0)
                    {
                        repeat = "5";//代表成功
                    }
                }
            }
            response = "{\"success\":\"" + repeat + "\"}";
            Response.Write(response);
            Response.End();
        }
Example #5
0
        public WEB_CUSTOMSCOST JsonToEntity(JObject json)
        {
            WEB_CUSTOMSCOST en = new WEB_CUSTOMSCOST();

            try
            {
                if (!string.IsNullOrEmpty(json.Value <string>("ID")))
                {
                    en.ID = Convert.ToInt32(json.Value <string>("ID"));
                }
                else
                {
                    en.ID = -1;
                }
                en.BUSITYPECODE = json.Value <string>("BUSITYPECODE");
                string    sqlStr = "select * from web_customsconfig t1 where t1.busitypecode='" + en.BUSITYPECODE + "'";
                DataTable dt     = DBMgr.GetDataTable(sqlStr);
                en.BUSITYPENAME = dt.Rows[0]["busitypename"].ToString();
                en.BUSIITEMCODE = json.Value <string>("BUSIITEMCODE");
                sqlStr          = "select * from web_customsconfig t1 where t1.busiitemcode='" + en.BUSIITEMCODE + "'";
                dt = DBMgr.GetDataTable(sqlStr);
                en.BUSIITEMNAME = dt.Rows[0]["busiitemname"].ToString();
                en.CONFIGNAME   = json.Value <string>("CONFIGNAME");
                en.ORIGINNAME   = json.Value <string>("ORIGINNAME");
                FormsIdentity identity  = HttpContext.Current.User.Identity as FormsIdentity;
                string        userName  = identity.Name;
                JObject       json_user = Extension.Get_UserInfo(userName);
                en.CREATEUSERID   = (Int32)json_user.GetValue("ID");
                en.CREATEUSERNAME = (string)json_user.GetValue("REALNAME");
                en.REASON         = json.Value <string>("REASON");
                return(en);
            }
            catch
            {
                return(null);
            }
        }