コード例 #1
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public int Update(SqlTransaction sqltran, Entities.QS_Category model)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@QS_CID",           SqlDbType.Int,         4),
                new SqlParameter("@QS_RTID",          SqlDbType.Int,         4),
                new SqlParameter("@Name",             SqlDbType.NVarChar,  500),
                new SqlParameter("@Score",            SqlDbType.Int,         4),
                new SqlParameter("@Status",           SqlDbType.Int,         4),

                new SqlParameter("@LastModifyTime",   SqlDbType.DateTime),
                new SqlParameter("@LastModifyUserID", SqlDbType.Int,         4),
                new SqlParameter("@ScoreType",        SqlDbType.Int,         4),
                new SqlParameter("@Sort",             SqlDbType.Int, 4)
            };
            parameters[0].Value = model.QS_CID;
            parameters[1].Value = model.QS_RTID;
            parameters[2].Value = model.Name;
            parameters[3].Value = model.Score;
            parameters[4].Value = model.Status;

            parameters[5].Value = model.LastModifyTime;
            parameters[6].Value = model.LastModifyUserID;
            parameters[7].Value = model.ScoreType;
            parameters[8].Value = model.Sort;

            return(SqlHelper.ExecuteNonQuery(sqltran, CommandType.StoredProcedure, P_QS_CATEGORY_UPDATE, parameters));
        }
コード例 #2
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public int Insert(SqlTransaction sqltran, Entities.QS_Category model)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@QS_CID",           SqlDbType.Int,         4),
                new SqlParameter("@QS_RTID",          SqlDbType.Int,         4),
                new SqlParameter("@Name",             SqlDbType.NVarChar,  500),
                new SqlParameter("@Score",            SqlDbType.Int,         4),
                new SqlParameter("@Status",           SqlDbType.Int,         4),
                new SqlParameter("@CreateTime",       SqlDbType.DateTime),
                new SqlParameter("@CreateUserID",     SqlDbType.Int,         4),
                new SqlParameter("@LastModifyTime",   SqlDbType.DateTime),
                new SqlParameter("@LastModifyUserID", SqlDbType.Int,         4),
                new SqlParameter("@ScoreType",        SqlDbType.Int,         4),
                new SqlParameter("@Sort",             SqlDbType.Int, 4)
            };
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value     = model.QS_RTID;
            parameters[2].Value     = model.Name;
            parameters[3].Value     = model.Score;
            parameters[4].Value     = model.Status;
            parameters[5].Value     = model.CreateTime;
            parameters[6].Value     = model.CreateUserID;
            parameters[7].Value     = model.LastModifyTime;
            parameters[8].Value     = model.LastModifyUserID;
            parameters[9].Value     = model.ScoreType;
            parameters[10].Value    = model.Sort;

            SqlHelper.ExecuteNonQuery(sqltran, CommandType.StoredProcedure, P_QS_CATEGORY_INSERT, parameters);
            return((int)parameters[0].Value);
        }
コード例 #3
0
        private Entities.QS_Category LoadSingleQS_Category(DataRow row)
        {
            Entities.QS_Category model = new Entities.QS_Category();

            if (row["QS_CID"].ToString() != "")
            {
                model.QS_CID = int.Parse(row["QS_CID"].ToString());
            }
            if (row["QS_RTID"].ToString() != "")
            {
                model.QS_RTID = int.Parse(row["QS_RTID"].ToString());
            }
            model.Name = row["Name"].ToString();
            if (row["Score"].ToString() != "")
            {
                model.Score = int.Parse(row["Score"].ToString());
            }
            if (row["Status"].ToString() != "")
            {
                model.Status = int.Parse(row["Status"].ToString());
            }
            if (row["CreateTime"].ToString() != "")
            {
                model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
            }
            if (row["CreateUserID"].ToString() != "")
            {
                model.CreateUserID = int.Parse(row["CreateUserID"].ToString());
            }
            if (row["LastModifyTime"].ToString() != "")
            {
                model.LastModifyTime = DateTime.Parse(row["LastModifyTime"].ToString());
            }
            if (row["LastModifyUserID"].ToString() != "")
            {
                model.LastModifyUserID = int.Parse(row["LastModifyUserID"].ToString());
            }
            if (row["ScoreType"].ToString() != "")
            {
                model.ScoreType = int.Parse(row["ScoreType"].ToString());
            }
            if (row["Sort"].ToString() != "")
            {
                model.Sort = int.Parse(row["Sort"].ToString());
            }
            return(model);
        }
コード例 #4
0
        private void Submit(out string msg, int userID, out string returnRTID)
        {
            msg        = "";
            returnRTID = "";

            #region 定义变量

            string         datainfoStr = DataStr;
            ScoreTableInfo tempInfoData;

            Entities.QS_RulesTable      QsTable;
            Entities.QS_Category        QsCategory;
            Entities.QS_Item            QsItem;
            Entities.QS_Standard        QsStandard;
            Entities.QS_Marking         QsMarking;
            Entities.QS_DeadOrAppraisal Qsdead;


            List <Entities.QS_Category>        QsCategoryList = new List <Entities.QS_Category>();
            List <Entities.QS_Item>            QsItemList     = new List <Entities.QS_Item>();
            List <Entities.QS_Standard>        QsStandardList = new List <Entities.QS_Standard>();
            List <Entities.QS_Marking>         QsMarkingList  = new List <Entities.QS_Marking>();
            List <Entities.QS_DeadOrAppraisal> QsDeadList     = new List <Entities.QS_DeadOrAppraisal>();

            #endregion

            tempInfoData = (ScoreTableInfo)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(datainfoStr, typeof(ScoreTableInfo));

            #region 验证数据
            //判断是否是提交,提交才验证,add by qizq
            if (ActionType == "Submit")
            {
                CheckMsg(tempInfoData, out msg);

                if (msg != "")
                {
                    return;
                }
            }
            //
            #endregion

            #region 准备数据

            #region 评分表

            QsTable             = new Entities.QS_RulesTable();
            QsTable.QS_RTID     = int.Parse(tempInfoData.RTID);
            QsTable.Name        = tempInfoData.Name;
            QsTable.ScoreType   = int.Parse(tempInfoData.ScoreType);
            QsTable.Description = tempInfoData.Description;

            QsTable.DeadItemNum      = int.Parse(tempInfoData.DeadItemNum);
            QsTable.NoDeadItemNum    = int.Parse(tempInfoData.NoDeadItemNum);
            QsTable.HaveQAppraisal   = int.Parse(tempInfoData.Appraisal);
            QsTable.LastModifyTime   = DateTime.Now;
            QsTable.LastModifyUserID = userID.ToString();
            QsTable.RegionID         = tempInfoData.RegionID;

            if (QsTable.QS_RTID < 0)
            {
                if (BLL.QS_RulesTable.Instance.IsRuleTableNameExist(QsTable.Name, QsTable.ScoreType))
                {
                    msg = "评分表名称[" + QsTable.Name + "]已经存在,不能重复添加!";
                    return;
                }
            }

            //add by qizq 添加日志2013-5-8
            StringBuilder sbStr = new StringBuilder();

            if (ActionType == "Submit")
            {
                sbStr.Append("提交评分表 " + QsTable.Name);
                QsTable.Status = (int)Entities.QSRulesTableStatus.Audit;
            }
            else
            {
                sbStr.Append("保存评分表 " + QsTable.Name);
                QsTable.Status = (int)Entities.QSRulesTableStatus.Unfinished;
            }

            #endregion

            #region 评分分类

            if (tempInfoData.Catage != null)
            {
                foreach (Catage catageInfo in tempInfoData.Catage)
                {
                    QsCategory                  = new Entities.QS_Category();
                    QsCategory.QS_CID           = int.Parse(catageInfo.CID);
                    QsCategory.QS_RTID          = int.Parse(tempInfoData.RTID);//评分表的值
                    QsCategory.Name             = catageInfo.Name;
                    QsCategory.Score            = int.Parse(catageInfo.Score);
                    QsCategory.Status           = int.Parse(catageInfo.Status);
                    QsCategory.ScoreType        = int.Parse(tempInfoData.ScoreType); //评分表的值
                    QsCategory.LastModifyTime   = DateTime.Now;
                    QsCategory.LastModifyUserID = userID;

                    QsCategoryList.Add(QsCategory);

                    #region 质检项目

                    if (catageInfo.Item != null)
                    {
                        foreach (Item itemInfo in catageInfo.Item)
                        {
                            QsItem                  = new Entities.QS_Item();
                            QsItem.QS_IID           = int.Parse(itemInfo.IID);
                            QsItem.QS_CID           = int.Parse(catageInfo.CID);
                            QsItem.QS_RTID          = int.Parse(tempInfoData.RTID);
                            QsItem.ItemName         = itemInfo.ItemName;
                            QsItem.ScoreType        = int.Parse(tempInfoData.ScoreType);
                            QsItem.Score            = decimal.Parse(itemInfo.Score);
                            QsItem.Status           = int.Parse(itemInfo.Status);
                            QsItem.LastModifyTime   = DateTime.Now;
                            QsItem.LastModifyUserID = userID;

                            QsItemList.Add(QsItem);

                            #region 质检标准

                            if (itemInfo.Standard != null)
                            {
                                foreach (Standard standardInfo in itemInfo.Standard)
                                {
                                    if (standardInfo.Score.Trim() != "" && standardInfo.SName.Trim() != "") //&& standardInfo.Status.Trim() == "0"
                                    {
                                        QsStandard                     = new Entities.QS_Standard();
                                        QsStandard.QS_SID              = int.Parse(standardInfo.SID);
                                        QsStandard.QS_IID              = int.Parse(itemInfo.IID);
                                        QsStandard.QS_CID              = int.Parse(catageInfo.CID);
                                        QsStandard.QS_RTID             = int.Parse(tempInfoData.RTID);
                                        QsStandard.ScoringStandardName = standardInfo.SName;
                                        QsStandard.ScoreType           = int.Parse(tempInfoData.ScoreType);
                                        QsStandard.Score               = decimal.Parse(standardInfo.Score);
                                        QsStandard.IsIsDead            = string.IsNullOrEmpty(standardInfo.IsIsDead) ? -2 : int.Parse(standardInfo.IsIsDead);
                                        QsStandard.Status              = int.Parse(standardInfo.Status);
                                        QsStandard.LastModifyTime      = DateTime.Now;
                                        QsStandard.LastModifyUserID    = userID;

                                        QsStandard.QS_SExplanation = standardInfo.SExplanation;
                                        QsStandard.QS_SkillLevel   = standardInfo.SkillLevel == null ? Constant.INT_INVALID_VALUE: int.Parse(standardInfo.SkillLevel);

                                        QsStandardList.Add(QsStandard);
                                    }

                                    #region 扣分项

                                    if (standardInfo.Marking != null && tempInfoData.ScoreType.Trim() != "3")
                                    {
                                        foreach (Marking markInfo in standardInfo.Marking)
                                        {
                                            QsMarking = new Entities.QS_Marking();

                                            QsMarking.QS_MID          = int.Parse(markInfo.MID);
                                            QsMarking.QS_RTID         = int.Parse(tempInfoData.RTID);
                                            QsMarking.QS_CID          = int.Parse(catageInfo.CID);
                                            QsMarking.QS_IID          = int.Parse(itemInfo.IID);
                                            QsMarking.QS_SID          = int.Parse(standardInfo.SID);
                                            QsMarking.ScoreType       = int.Parse(tempInfoData.ScoreType);
                                            QsMarking.MarkingItemName = markInfo.MName;
                                            QsMarking.Score           = int.Parse(markInfo.Score);
                                            QsMarking.Status          = int.Parse(markInfo.Status);

                                            QsMarkingList.Add(QsMarking);
                                        }
                                    }

                                    #endregion
                                }
                            }


                            #endregion
                        }
                    }

                    #endregion
                }
            }

            #endregion

            #region 致命项

            if (tempInfoData.Dead != null)
            {
                foreach (Dead deadInfo in tempInfoData.Dead)
                {
                    Qsdead                  = new Entities.QS_DeadOrAppraisal();
                    Qsdead.QS_DAID          = int.Parse(deadInfo.DID);
                    Qsdead.QS_RTID          = int.Parse(tempInfoData.RTID);
                    Qsdead.DeadItemName     = deadInfo.DName;
                    Qsdead.Status           = int.Parse(deadInfo.Status);
                    Qsdead.LastModifyTime   = DateTime.Now;
                    Qsdead.LastModifyUserID = userID;

                    QsDeadList.Add(Qsdead);
                }
            }

            #endregion

            #endregion

            #region 提交到数据库

            string        connectionstrings = ConfigurationUtil.GetAppSettingValue("ConnectionStrings_CC");
            SqlConnection connection        = new SqlConnection(connectionstrings);
            connection.Open();
            SqlTransaction tran = connection.BeginTransaction(IsolationLevel.ReadUncommitted);
            //  SqlTransaction tran = connection.BeginTransaction("SampleTransaction");

            try
            {
                #region 保存评分表

                if (QsTable.QS_RTID < 0)
                {
                    //新增

                    QsTable.CreateTime   = DateTime.Now;
                    QsTable.CreateUserID = userID;
                    int retID = BLL.QS_RulesTable.Instance.Insert(tran, QsTable);
                    returnRTID = retID.ToString();

                    #region 修改各个表的评分表ID

                    foreach (Entities.QS_Category cItem in QsCategoryList)
                    {
                        if (cItem.QS_RTID == QsTable.QS_RTID)
                        {
                            cItem.QS_RTID = int.Parse(returnRTID);
                        }
                    }

                    foreach (Entities.QS_Item iItem in QsItemList)
                    {
                        if (iItem.QS_RTID == QsTable.QS_RTID)
                        {
                            iItem.QS_RTID = int.Parse(returnRTID);
                        }
                    }

                    foreach (Entities.QS_Standard sItem in QsStandardList)
                    {
                        if (sItem.QS_RTID == QsTable.QS_RTID)
                        {
                            sItem.QS_RTID = int.Parse(returnRTID);
                        }
                    }

                    foreach (Entities.QS_Marking mItem in QsMarkingList)
                    {
                        if (mItem.QS_RTID == QsTable.QS_RTID)
                        {
                            mItem.QS_RTID = int.Parse(returnRTID);
                        }
                    }

                    foreach (Entities.QS_DeadOrAppraisal dItem in QsDeadList)
                    {
                        if (dItem.QS_RTID == QsTable.QS_RTID)
                        {
                            dItem.QS_RTID = int.Parse(returnRTID);
                        }
                    }

                    #endregion
                }
                else
                {
                    //编辑
                    BLL.QS_RulesTable.Instance.Update(tran, QsTable);
                    returnRTID = QsTable.QS_RTID.ToString();
                }

                #endregion

                #region 保存分类

                foreach (Entities.QS_Category cItem in QsCategoryList)
                {
                    if (cItem.Status == -1)
                    {
                        //删除的
                        BLL.QS_Category.Instance.Delete(tran, cItem.QS_CID);
                        continue;
                    }

                    if (cItem.QS_CID < 0)
                    {
                        //新增
                        cItem.CreateTime   = DateTime.Now;
                        cItem.CreateUserID = userID;
                        int retCID = BLL.QS_Category.Instance.Insert(tran, cItem);

                        #region 修改各个表的分类ID

                        foreach (Entities.QS_Item iItem in QsItemList)
                        {
                            if (iItem.QS_CID == cItem.QS_CID)
                            {
                                iItem.QS_CID = retCID;
                            }
                        }

                        foreach (Entities.QS_Standard sItem in QsStandardList)
                        {
                            if (sItem.QS_CID == cItem.QS_CID)
                            {
                                sItem.QS_CID = retCID;
                            }
                        }

                        foreach (Entities.QS_Marking mItem in QsMarkingList)
                        {
                            if (mItem.QS_CID == cItem.QS_CID)
                            {
                                mItem.QS_CID = retCID;
                            }
                        }

                        #endregion
                    }
                    else
                    {
                        //编辑
                        BLL.QS_Category.Instance.Update(tran, cItem);
                    }
                }

                #endregion

                #region 保存项目

                foreach (Entities.QS_Item iItem in QsItemList)
                {
                    if (iItem.Status == -1)
                    {
                        //删除的
                        BLL.QS_Item.Instance.Delete(tran, iItem.QS_IID);
                        continue;
                    }

                    if (iItem.QS_IID < 0)
                    {
                        //新增
                        iItem.CreateTime   = DateTime.Now;
                        iItem.CreateUserID = userID;
                        int retIID = BLL.QS_Item.Instance.Insert(tran, iItem);

                        #region 修改各个表的项目ID

                        foreach (Entities.QS_Standard sItem in QsStandardList)
                        {
                            if (sItem.QS_IID == iItem.QS_IID)
                            {
                                sItem.QS_IID = retIID;
                            }
                        }

                        foreach (Entities.QS_Marking mItem in QsMarkingList)
                        {
                            if (mItem.QS_IID == iItem.QS_IID)
                            {
                                mItem.QS_IID = retIID;
                            }
                        }

                        #endregion
                    }
                    else
                    {
                        //编辑
                        BLL.QS_Item.Instance.Update(tran, iItem);
                    }
                }

                #endregion

                #region 保存质检标准

                foreach (Entities.QS_Standard sItem in QsStandardList)
                {
                    if (sItem.Status == -1)
                    {
                        //删除的
                        BLL.QS_Standard.Instance.Delete(tran, sItem.QS_SID);
                        continue;
                    }

                    if (sItem.QS_SID < 0 || (sItem.ScoreType == 3 && sItem.QS_SID <= 5))
                    {
                        //新增
                        sItem.CreateTime   = DateTime.Now;
                        sItem.CreateUserID = userID;
                        int retSID = BLL.QS_Standard.Instance.Insert(tran, sItem);

                        #region 修改各个表的项目ID
                        if (sItem.ScoreType != 3)
                        {
                            foreach (Entities.QS_Marking mItem in QsMarkingList)
                            {
                                if (mItem.QS_SID == sItem.QS_SID)
                                {
                                    mItem.QS_SID = retSID;
                                }
                            }
                        }
                        #endregion
                    }
                    else
                    {
                        //编辑
                        BLL.QS_Standard.Instance.Update(tran, sItem);
                    }
                }

                #endregion

                #region 保存评分扣分项

                foreach (Entities.QS_Marking mItem in QsMarkingList)
                {
                    if (mItem.Status == -1)
                    {
                        //删除的
                        BLL.QS_Marking.Instance.Delete(tran, mItem.QS_MID);
                        continue;
                    }

                    if (mItem.QS_MID < 0)
                    {
                        //新增
                        mItem.CreateTime   = DateTime.Now;
                        mItem.CreateUserID = userID;
                        BLL.QS_Marking.Instance.Insert(tran, mItem);
                    }
                    else
                    {
                        //编辑
                        BLL.QS_Marking.Instance.Update(tran, mItem);
                    }
                }

                #endregion

                #region 保存致命项

                foreach (Entities.QS_DeadOrAppraisal dItem in QsDeadList)
                {
                    if (dItem.Status == -1)
                    {
                        //删除的
                        BLL.QS_DeadOrAppraisal.Instance.Delete(tran, dItem.QS_DAID);
                        continue;
                    }

                    if (dItem.QS_DAID < 0)
                    {
                        //新增
                        dItem.CreateTime   = DateTime.Now;
                        dItem.CreateUserID = userID;
                        BLL.QS_DeadOrAppraisal.Instance.Insert(tran, dItem);
                    }
                    else
                    {
                        //编辑
                        BLL.QS_DeadOrAppraisal.Instance.Update(tran, dItem);
                    }
                }

                #endregion

                //add by qizq 保存日志 2013-5-8
                BLL.Util.InsertUserLog(tran, sbStr.ToString());

                tran.Commit();
            }
            catch (Exception ex)
            {
                if (tran.Connection != null)
                {
                    tran.Rollback();
                }
                msg = ex.Message.ToString();
            }
            finally
            {
                connection.Close();
            }


            #endregion
        }
コード例 #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(SqlTransaction sqltran, Entities.QS_Category model)
 {
     return(Dal.QS_Category.Instance.Update(sqltran, model));
 }
コード例 #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(Entities.QS_Category model)
 {
     return(Dal.QS_Category.Instance.Update(model));
 }
コード例 #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Insert(Entities.QS_Category model)
 {
     return(Dal.QS_Category.Instance.Insert(model));
 }