Example #1
0
        public string AddRunRecrod(SqlCommand command, MDRunRecordFileMain model, Boolean isExitPlan, int a)
        {
            string sqlConnString = ZhuanChuString;
            string DetailTime    = DateTime.Now.ToString();
            int    DetaieCount   = a;

            if (ZhuanChuIsEnable == "1")
            {
                try
                {
                    if (!string.IsNullOrEmpty(model.strTrainmanNumber1) && model.dtPlanChuQinTime > DateTime.Now.AddDays(-1000))
                    {
                        DataTable dt = getMaxTimeAndCount(model.dtPlanChuQinTime.ToString(), model.strTrainmanNumber1);
                        if (ObjectConvertClass.static_ext_int(dt.Rows[0]["DetaieCount"]) != 0)
                        {
                            DetaieCount = ObjectConvertClass.static_ext_int(dt.Rows[0]["DetaieCount"]);
                            DetailTime  = ObjectConvertClass.static_ext_string(dt.Rows[0]["DetailTime"]);
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            StringBuilder strSql = new StringBuilder();

            strSql.Append("DECLARE @ROWGUID_EndWork_RunRecrod_Main TABLE(ID uniqueidentifier) ");
            strSql.Append("insert into Tab_EndWork_RunRecrod_Main ");
            strSql.Append("(dtUploadTime,strPlanGUID,dtPlanChuQinTime,strTrainNo,strTrainNum,strTrainTypeName,strTrainmanNumber1,strTrainmanName1,strTrainmanNumber2,strTrainmanName2,strTrainmanNumber3,strTrainmanName3,strTrainmanNumber4,strTrainmanName4,strCardNumber,strSiteNumber,strSiteName,dtLastUpDateTime,nDetailCount)");
            strSql.Append("OUTPUT INSERTED.STRGUID INTO @ROWGUID_EndWork_RunRecrod_Main ");
            strSql.Append("values(@dtUploadTime,@strPlanGUID,@dtPlanChuQinTime,@strTrainNo,@strTrainNum,@strTrainTypeName,@strTrainmanNumber1,@strTrainmanName1,@strTrainmanNumber2,@strTrainmanName2,@strTrainmanNumber3,@strTrainmanName3,@strTrainmanNumber4,@strTrainmanName4,@strCardNumber,@strSiteNumber,@strSiteName,@dtLastUpDateTime,@nDetailCount)");
            strSql.Append(";SELECT ID FROM @ROWGUID_EndWork_RunRecrod_Main");
            SqlParameter[] parameters =
            {
                new SqlParameter("@dtUploadTime",       model.dtUploadTime),
                new SqlParameter("@strPlanGUID",        model.strPlanGUID),
                new SqlParameter("@dtPlanChuQinTime",   model.dtPlanChuQinTime),
                new SqlParameter("@strTrainNo",         model.strTrainNo),
                new SqlParameter("@strTrainNum",        model.strTrainNum),
                new SqlParameter("@strTrainTypeName",   model.strTrainTypeName),
                new SqlParameter("@strTrainmanNumber1", model.strTrainmanNumber1),
                new SqlParameter("@strTrainmanName1",   model.strTrainmanName1),
                new SqlParameter("@strTrainmanNumber2", model.strTrainmanNumber2),
                new SqlParameter("@strTrainmanName2",   model.strTrainmanName2),
                new SqlParameter("@strTrainmanNumber3", model.strTrainmanNumber3),
                new SqlParameter("@strTrainmanName3",   model.strTrainmanName3),
                new SqlParameter("@strTrainmanNumber4", model.strTrainmanNumber4),
                new SqlParameter("@strTrainmanName4",   model.strTrainmanName4),
                new SqlParameter("@strCardNumber",      model.strCardNumber),
                new SqlParameter("@strSiteNumber",      model.strSiteNumber),
                new SqlParameter("@strSiteName",        model.strSiteName),
                new SqlParameter("@nDetailCount",       DetaieCount),
                new SqlParameter("@dtLastUpDateTime",   DetailTime)
            };
            command.CommandText = strSql.ToString();
            command.Parameters.Clear();
            command.Parameters.AddRange(parameters);

            return(ObjectConvertClass.static_ext_string(command.ExecuteScalar()));
            //return  command.ExecuteNonQuery();
        }
Example #2
0
        /// <summary>
        /// 提交运行记录转储记录
        /// </summary>
        public void SubMitRunRecordInfo(MDRunRecordFileMain runRecordFileMain)
        {
            SqlConnection  connection  = new SqlConnection();
            SqlTransaction transaction = null;
            SqlCommand     command     = new SqlCommand();

            command.Connection          = connection;
            connection.ConnectionString = SqlHelper.ConnString;
            try
            {
                connection.Open();
                transaction         = connection.BeginTransaction();
                command.Transaction = transaction;
                string  strTrainPlanGUID = "";
                Boolean isExitPlan       = true;
                //客户端如未传入计划GUID,则根据工号和当前时间检索数据库内符合的退勤计划
                if (string.IsNullOrEmpty(runRecordFileMain.strPlanGUID))
                {
                    strTrainPlanGUID = getTrainPlanGUID(runRecordFileMain.strTrainmanNumber1);
                    if (string.IsNullOrEmpty(strTrainPlanGUID))
                    {
                        runRecordFileMain.strPlanGUID = Guid.NewGuid().ToString();
                        isExitPlan = false;
                    }
                    else
                    {
                        runRecordFileMain.strPlanGUID = strTrainPlanGUID;
                        isExitPlan = true;
                    }
                }
                else
                {
                    strTrainPlanGUID = runRecordFileMain.strPlanGUID;
                    isExitPlan       = true;
                }

                //判断表中是否已经存在主记录
                int    MainCount = getMainCount(strTrainPlanGUID);
                string strGUID   = "";
                if (MainCount < 1)
                {
                    strGUID = AddRunRecrod(command, runRecordFileMain, isExitPlan, runRecordFileMain.RunRecordFileDetailList.Count);
                }
                else
                {
                    strGUID = Guid.NewGuid().ToString();
                }


                //向子表中插入转储记录
                for (int i = 0; i < runRecordFileMain.RunRecordFileDetailList.Count; i++)
                {
                    runRecordFileMain.RunRecordFileDetailList[i].strRecordGUID = strGUID;
                    AddRecordFileDetail(command, runRecordFileMain.RunRecordFileDetailList[i]);
                }
                transaction.Commit();
            }
            catch (Exception ex)
            {
                LogClass.log("Interface.SubMitRunRecordInfo:" + ex.Message);
                throw ex;
            }
        }