Beispiel #1
0
        /// <summary>
        /// 得到一个对象实体 主表
        /// </summary>
        public SCZM.Model.Repair.repair_AccessoriesBill GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,IntentionId,GetAccessoriesDate,AllFee,AllFee_actual,Memo,FlagDel,OperaDepId,OperaId,OperaName,OperaTime,UserName,BillType from repair_AccessoriesBill ");
            strSql.Append(" where FlagDel=0 and ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            SCZM.Model.Repair.repair_AccessoriesBill model = new SCZM.Model.Repair.repair_AccessoriesBill();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                #region  父表信息
                model = DataRowToModel(ds.Tables[0].Rows[0]);
                #endregion  父表信息end

                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 得到一个对象实体 子方法 从DataRow中
 /// </summary>
 public SCZM.Model.Repair.repair_AccessoriesBill DataRowToModel(DataRow row)
 {
     SCZM.Model.Repair.repair_AccessoriesBill model = new SCZM.Model.Repair.repair_AccessoriesBill();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["IntentionId"] != null && row["IntentionId"].ToString() != "")
         {
             model.IntentionId = int.Parse(row["IntentionId"].ToString());
         }
         if (row["GetAccessoriesDate"] != null && row["GetAccessoriesDate"].ToString() != "")
         {
             model.GetAccessoriesDate = DateTime.Parse(row["GetAccessoriesDate"].ToString());
         }
         if (row["AllFee"] != null && row["AllFee"].ToString() != "")
         {
             model.AllFee = decimal.Parse(row["AllFee"].ToString());
         }
         if (row["AllFee_actual"] != null && row["AllFee_actual"].ToString() != "")
         {
             model.AllFee_actual = decimal.Parse(row["AllFee_actual"].ToString());
         }
         if (row["Memo"] != null)
         {
             model.Memo = row["Memo"].ToString();
         }
         if (row["BillType"] != null && row["BillType"].ToString() != "")
         {
             model.BillType = int.Parse(row["BillType"].ToString());
         }
         if (row["FlagDel"] != null && row["FlagDel"].ToString() != "")
         {
             model.FlagDel = int.Parse(row["FlagDel"].ToString());
         }
         if (row["OperaDepId"] != null && row["OperaDepId"].ToString() != "")
         {
             model.OperaDepId = int.Parse(row["OperaDepId"].ToString());
         }
         if (row["OperaId"] != null && row["OperaId"].ToString() != "")
         {
             model.OperaId = int.Parse(row["OperaId"].ToString());
         }
         if (row["OperaName"] != null)
         {
             model.OperaName = row["OperaName"].ToString();
         }
         if (row["OperaTime"] != null && row["OperaTime"].ToString() != "")
         {
             model.OperaTime = DateTime.Parse(row["OperaTime"].ToString());
         }
         if (row["UserName"] != null)
         {
             model.OperaName = row["UserName"].ToString();
         }
     }
     return(model);
 }
Beispiel #3
0
        private void SaveData(HttpContext context, string btn)
        {
            if (btn != "btnSave")
            {
                context.Response.Write("{\"status\":\"0.2\",\"msg\":\"对不起,您没有操作权限!\"}");
                return;
            }
            string ID                    = RequestHelper.GetString("ID");
            string IntentionId           = RequestHelper.GetString("IntentionId");
            string GetAccessoriesDate    = RequestHelper.GetString("GetAccessoriesDate");
            string UserName              = RequestHelper.GetString("UserName");
            string AllFee                = RequestHelper.GetString("AllFee");
            string AllFee_actual         = RequestHelper.GetString("AllFee_actual");
            string Memo                  = RequestHelper.GetString("Memo");
            string detailStr_Accessories = RequestHelper.GetString("detailStr_Accessories");
            string BillType              = RequestHelper.GetString("BillType");

            Model.System.sys_LoginUser loginUserModel      = BaseWeb.GetLoginInfo();
            SCZM.Model.Repair.repair_AccessoriesBill model = new SCZM.Model.Repair.repair_AccessoriesBill();
            SCZM.BLL.Repair.repair_AccessoriesBill   bll   = new SCZM.BLL.Repair.repair_AccessoriesBill();
            model.ID          = Utils.StrToInt(ID, 0);
            model.IntentionId = Utils.StrToInt(IntentionId, 0);
            if (GetAccessoriesDate != "")
            {
                model.GetAccessoriesDate = Utils.StrToDateTime(GetAccessoriesDate);
            }
            model.UserName      = UserName;
            model.AllFee        = Utils.StrToDecimal(AllFee, 0);
            model.AllFee_actual = Utils.StrToDecimal(AllFee_actual, 0);
            model.BillType      = Utils.StrToInt(BillType, 0);
            model.Memo          = Memo;
            model.OperaDepId    = loginUserModel.DepId;
            model.OperaId       = loginUserModel.ID;
            model.OperaName     = loginUserModel.PerName;
            model.OperaTime     = DateTime.Now;

            List <Model.Repair.repair_AccessoriesBill_Accessories> model_detail = new List <Model.Repair.repair_AccessoriesBill_Accessories>();

            Model.Repair.repair_AccessoriesBill_Accessories models = new Model.Repair.repair_AccessoriesBill_Accessories();
            if (detailStr_Accessories != "")
            {
                string[] detailRow = detailStr_Accessories.Split('≮');
                for (int i = 0; i < detailRow.Length; i++)
                {
                    string[] detailCell = detailRow[i].Split('⊥');
                    models = new Model.Repair.repair_AccessoriesBill_Accessories();
                    models.AccessoriesId   = Utils.StrToInt(detailCell[0], 0);
                    models.AccessoriesNat  = Utils.StrToInt(detailCell[1], 0);
                    models.AccessoriesNum  = Utils.StrToInt(detailCell[2], 0);
                    models.AccessoriesFee  = Utils.StrToInt(detailCell[3], 0);
                    models.AccessoriesMemo = detailCell[4];
                    models.AccessoriesDate = Utils.StrToDateTime(detailCell[5], DateTime.Now);
                    model_detail.Add(models);
                }
                model.repair_AccessoriesBill_Accessoriess = model_detail;
            }

            string operaMessage = "";
            string status       = "0";
            string operaAction  = "";
            string operaMemo    = "";

            try
            {
                if (ID == "")
                {
                    model.ID = bll.Add(model, out operaMessage);
                    if (model.ID > 0)
                    {
                        status      = "1";
                        operaAction = Enums.ActionEnum.Add.ToString();
                        operaMemo   = "新增辅料明细:" + model.ID;
                    }
                }
                else
                {
                    if (bll.Update(model, out operaMessage))
                    {
                        status      = "1";
                        operaAction = Enums.ActionEnum.Edit.ToString();
                        operaMemo   = "修改辅料明细:" + model.ID;
                    }
                }
                if (status == "1")
                {
                    //写入操作日志
                    BaseWeb.AddOpera(loginUserModel, int.Parse(RequestHelper.GetQueryString("MenuId")), operaAction, operaMemo);
                }
                context.Response.Write("{\"status\":\"" + status + "\",\"msg\":\"" + operaMessage + "\"}");
                return;
            }
            catch (Exception e)
            {
                context.Response.Write("{\"status\":\"0\",\"msg\":\"对不起,系统出错:" + Utils.HtmlEncode(e.Message) + "\"}");
                return;
            }
        }
Beispiel #4
0
        /// <summary>
        /// 增加一条数据,及其子表数据
        /// </summary>
        public int Add(SCZM.Model.Repair.repair_AccessoriesBill model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into repair_AccessoriesBill(");
            strSql.Append("IntentionId,GetAccessoriesDate,AllFee,AllFee_actual,Memo,FlagDel,OperaDepId,OperaId,OperaName,OperaTime,UserName,BillType)");
            strSql.Append(" values (");
            strSql.Append("@IntentionId,@GetAccessoriesDate,@AllFee,@AllFee_actual,@Memo,@FlagDel,@OperaDepId,@OperaId,@OperaName,@OperaTime,@UserName,@BillType)");
            strSql.Append(";set @ReturnValue= @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@IntentionId",        SqlDbType.Int,              4),
                new SqlParameter("@GetAccessoriesDate", SqlDbType.SmallDateTime),
                new SqlParameter("@AllFee",             SqlDbType.Decimal,          9),
                new SqlParameter("@AllFee_actual",      SqlDbType.Decimal,          9),
                new SqlParameter("@Memo",               SqlDbType.NVarChar,       200),
                new SqlParameter("@FlagDel",            SqlDbType.Int,              4),
                new SqlParameter("@OperaDepId",         SqlDbType.Int,              4),
                new SqlParameter("@OperaId",            SqlDbType.Int,              4),
                new SqlParameter("@OperaName",          SqlDbType.NVarChar,        10),
                new SqlParameter("@OperaTime",          SqlDbType.DateTime),
                new SqlParameter("@UserName",           SqlDbType.NVarChar,        10),
                new SqlParameter("@BillType",           SqlDbType.Int,              4),
                new SqlParameter("@ReturnValue",        SqlDbType.Int)
            };
            parameters[0].Value      = model.IntentionId;
            parameters[1].Value      = model.GetAccessoriesDate;
            parameters[2].Value      = model.AllFee;
            parameters[3].Value      = model.AllFee_actual;
            parameters[4].Value      = model.Memo;
            parameters[5].Value      = model.FlagDel;
            parameters[6].Value      = model.OperaDepId;
            parameters[7].Value      = model.OperaId;
            parameters[8].Value      = model.OperaName;
            parameters[9].Value      = model.OperaTime;
            parameters[10].Value     = model.UserName;
            parameters[11].Value     = model.BillType;
            parameters[12].Direction = ParameterDirection.Output;

            List <CommandInfo> sqllist = new List <CommandInfo>();
            CommandInfo        cmd     = new CommandInfo(strSql.ToString(), parameters);

            sqllist.Add(cmd);

            StringBuilder strSql2;

            if (model.repair_AccessoriesBill_Accessoriess != null)
            {
                foreach (SCZM.Model.Repair.repair_AccessoriesBill_Accessories models in model.repair_AccessoriesBill_Accessoriess)
                {
                    strSql2 = new StringBuilder();
                    strSql2.Append("insert into repair_AccessoriesBill_Accessories(");
                    strSql2.Append("AccessoriesBillId,AccessoriesDate,AccessoriesId,AccessoriesNum,AccessoriesNat,AccessoriesFee,FlagDel,AccessoriesMemo)");
                    strSql2.Append(" values (");
                    strSql2.Append("@AccessoriesBillId,@AccessoriesDate,@AccessoriesId,@AccessoriesNum,@AccessoriesNat,@AccessoriesFee,@FlagDel,@AccessoriesMemo)");
                    SqlParameter[] parameters2 =
                    {
                        new SqlParameter("@AccessoriesBillId", SqlDbType.Int,            4),
                        new SqlParameter("@AccessoriesDate",   SqlDbType.SmallDateTime),
                        new SqlParameter("@AccessoriesId",     SqlDbType.Int,            4),
                        new SqlParameter("@AccessoriesNum",    SqlDbType.Decimal,        9),
                        new SqlParameter("@AccessoriesNat",    SqlDbType.Decimal,        9),
                        new SqlParameter("@AccessoriesFee",    SqlDbType.Decimal,        9),
                        new SqlParameter("@FlagDel",           SqlDbType.Int,            4),
                        new SqlParameter("@AccessoriesMemo",   SqlDbType.NVarChar, 200)
                    };
                    parameters2[0].Direction = ParameterDirection.InputOutput;
                    parameters2[1].Value     = models.AccessoriesDate;
                    parameters2[2].Value     = models.AccessoriesId;
                    parameters2[3].Value     = models.AccessoriesNum;
                    parameters2[4].Value     = models.AccessoriesNat;
                    parameters2[5].Value     = models.AccessoriesFee;
                    parameters2[6].Value     = models.FlagDel;
                    parameters2[7].Value     = models.AccessoriesMemo;

                    cmd = new CommandInfo(strSql2.ToString(), parameters2);
                    sqllist.Add(cmd);
                }
            }
            DbHelperSQL.ExecuteSqlTranWithIndentity(sqllist);
            return((int)parameters[12].Value);
        }
Beispiel #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(SCZM.Model.Repair.repair_AccessoriesBill model)
        {
            List <CommandInfo> sqllist = new List <CommandInfo>();
            CommandInfo        cmd     = null;
            StringBuilder      strSql  = new StringBuilder();

            strSql.Append("update repair_AccessoriesBill set ");
            strSql.Append("IntentionId=@IntentionId,");
            strSql.Append("GetAccessoriesDate=@GetAccessoriesDate,");
            strSql.Append("AllFee=@AllFee,");
            strSql.Append("AllFee_actual=@AllFee_actual,");
            strSql.Append("Memo=@Memo,");
            strSql.Append("FlagDel=@FlagDel,");
            strSql.Append("OperaDepId=@OperaDepId,");
            strSql.Append("OperaId=@OperaId,");
            strSql.Append("OperaName=@OperaName,");
            strSql.Append("OperaTime=@OperaTime,");
            strSql.Append("UserName=@UserName,");
            strSql.Append("BillType=@BillType");
            strSql.Append(" where FlagDel=0 and ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@IntentionId",        SqlDbType.Int,              4),
                new SqlParameter("@GetAccessoriesDate", SqlDbType.SmallDateTime),
                new SqlParameter("@AllFee",             SqlDbType.Decimal,          9),
                new SqlParameter("@AllFee_actual",      SqlDbType.Decimal,          9),
                new SqlParameter("@Memo",               SqlDbType.NVarChar,       200),
                new SqlParameter("@FlagDel",            SqlDbType.Int,              4),
                new SqlParameter("@OperaDepId",         SqlDbType.Int,              4),
                new SqlParameter("@OperaId",            SqlDbType.Int,              4),
                new SqlParameter("@OperaName",          SqlDbType.NVarChar,        10),
                new SqlParameter("@OperaTime",          SqlDbType.DateTime),
                new SqlParameter("@UserName",           SqlDbType.NVarChar,        10),
                new SqlParameter("@BillType",           SqlDbType.Int,              4),
                new SqlParameter("@ID",                 SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.IntentionId;
            parameters[1].Value  = model.GetAccessoriesDate;
            parameters[2].Value  = model.AllFee;
            parameters[3].Value  = model.AllFee_actual;
            parameters[4].Value  = model.Memo;
            parameters[5].Value  = model.FlagDel;
            parameters[6].Value  = model.OperaDepId;
            parameters[7].Value  = model.OperaId;
            parameters[8].Value  = model.OperaName;
            parameters[9].Value  = model.OperaTime;
            parameters[10].Value = model.UserName;
            parameters[11].Value = model.BillType;
            parameters[12].Value = model.ID;

            cmd = new CommandInfo(strSql.ToString(), parameters);
            sqllist.Add(cmd);

            StringBuilder strSql2 = new StringBuilder();

            strSql2.Append("delete from  repair_AccessoriesBill_Accessories where AccessoriesBillId=@AccessoriesBillId ");
            SqlParameter[] parameters2 =
            {
                new SqlParameter("@AccessoriesBillId", SqlDbType.Int, 4)
            };
            parameters2[0].Value = model.ID;
            cmd = new CommandInfo(strSql2.ToString(), parameters2);
            sqllist.Add(cmd);

            StringBuilder strSql3;

            if (model.repair_AccessoriesBill_Accessoriess != null)
            {
                foreach (SCZM.Model.Repair.repair_AccessoriesBill_Accessories models in model.repair_AccessoriesBill_Accessoriess)
                {
                    strSql3 = new StringBuilder();
                    strSql3.Append("insert into repair_AccessoriesBill_Accessories(");
                    strSql3.Append("AccessoriesBillId,AccessoriesDate,AccessoriesId,AccessoriesNum,AccessoriesNat,AccessoriesFee,FlagDel,AccessoriesMemo)");
                    strSql3.Append(" values (");
                    strSql3.Append("@AccessoriesBillId,@AccessoriesDate,@AccessoriesId,@AccessoriesNum,@AccessoriesNat,@AccessoriesFee,@FlagDel,@AccessoriesMemo)");
                    SqlParameter[] parameters3 =
                    {
                        new SqlParameter("@AccessoriesBillId", SqlDbType.Int,            4),
                        new SqlParameter("@AccessoriesDate",   SqlDbType.SmallDateTime),
                        new SqlParameter("@AccessoriesId",     SqlDbType.Int,            4),
                        new SqlParameter("@AccessoriesNum",    SqlDbType.Decimal,        9),
                        new SqlParameter("@AccessoriesNat",    SqlDbType.Decimal,        9),
                        new SqlParameter("@AccessoriesFee",    SqlDbType.Decimal,        9),
                        new SqlParameter("@FlagDel",           SqlDbType.Int,            4),
                        new SqlParameter("@AccessoriesMemo",   SqlDbType.NVarChar, 200)
                    };
                    parameters3[0].Value = model.ID;
                    parameters3[1].Value = models.AccessoriesDate;
                    parameters3[2].Value = models.AccessoriesId;
                    parameters3[3].Value = models.AccessoriesNum;
                    parameters3[4].Value = models.AccessoriesNat;
                    parameters3[5].Value = models.AccessoriesFee;
                    parameters3[6].Value = models.FlagDel;
                    parameters3[7].Value = models.AccessoriesMemo;

                    cmd = new CommandInfo(strSql3.ToString(), parameters3);
                    sqllist.Add(cmd);
                }
            }
            int rows = DbHelperSQL.ExecuteSqlTran(sqllist);

            return(rows);
        }