コード例 #1
0
        public InterfaceOutPut ChangeJiaoLu(string data)
        {
            InterfaceOutPut      output = new InterfaceOutPut();
            JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();

            Group group = new Group();

            try
            {
                ChangeGrpJlParam InParams = javaScriptSerializer.Deserialize <ChangeGrpJlParam>(data);
                if (!LCGroup.GetGroup(InParams.GroupGUID, group))
                {
                    throw new Exception("没有找到对应的机组");
                }
                //可能还需要更新PLACEID


                if (!string.IsNullOrEmpty(group.trainPlanID))
                {
                    throw new Exception("该机组已按排计划,不能修改所属交路");
                }
                SqlParameter[] sqlParams = new SqlParameter[] {
                    new SqlParameter("strGroupGUID", InParams.GroupGUID),
                    new SqlParameter("DestJiaoLu", InParams.DestJiaolu.jiaoluID),
                    new SqlParameter("TrainGUID", InParams.TrainGUID),
                    new SqlParameter("nOrder", 0)
                };

                //获取最大序号
                string strSql = "select ISNUll(max(nOrder),1) from TAB_Nameplate_TrainmanJiaolu_OrderInTrain where strTrainGUID = @TrainGUID";

                int nOrder = Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.ConnString, CommandType.Text, strSql, sqlParams));

                nOrder++;
                sqlParams[sqlParams.Length - 1].SqlValue = nOrder;

                SqlConnection conn = new SqlConnection(SqlHelper.ConnString);
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        switch (InParams.SrcJiaolu.jiaoluType)
                        {
                        //记名式
                        case 2:
                        {
                            strSql = "delete from TAB_Nameplate_TrainmanJiaolu_Named where strGroupGUID = @strGroupGUID";
                            SqlHelper.ExecuteNonQuery(trans, CommandType.Text, strSql, sqlParams);
                            break;
                        }

                        //轮乘
                        case 3:
                        {
                            strSql = "delete from TAB_Nameplate_TrainmanJiaolu_Order where strGroupGUID = @strGroupGUID";
                            SqlHelper.ExecuteNonQuery(trans, CommandType.Text, strSql, sqlParams);
                            break;
                        }

                        //包乘
                        case 4:
                        {
                            //strSql = "delete from TAB_Nameplate_TrainmanJiaolu_OrderInTrain where strGroupGUID = @strGroupGUID";
                            //SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql, sqlParams);
                            break;
                        }
                        }

                        strSql = "update TAB_Nameplate_TrainmanJiaolu_OrderInTrain set strTrainGUID = @TrainGUID,nOrder = @nOrder where strGroupGUID = @strGroupGUID";
                        if (Convert.ToInt32(SqlHelper.ExecuteNonQuery(trans, CommandType.Text, strSql, sqlParams)) == 0)
                        {
                            //插入关联信息
                            strSql = @"insert into TAB_Nameplate_TrainmanJiaolu_OrderInTrain (strTrainGUID,nOrder,strGroupGUID) values(@TrainGUID,@nOrder,@strGroupGUID)";
                            SqlHelper.ExecuteNonQuery(trans, CommandType.Text, strSql, sqlParams);
                        }



                        //更新人员所属交路
                        strSql = @"update TAB_Org_Trainman set strTrainmanJiaoluGUID = @DestJiaoLu where strTrainmanGUID in (
                        select strTrainmanGUID1 from TAB_Nameplate_Group where strGroupGUID = @strGroupGUID
                        union
                        select strTrainmanGUID2 from TAB_Nameplate_Group where strGroupGUID = @strGroupGUID
                        union
                        select strTrainmanGUID3 from TAB_Nameplate_Group where strGroupGUID = @strGroupGUID
                        union
                        select strTrainmanGUID4 from TAB_Nameplate_Group where strGroupGUID = @strGroupGUID)";


                        SqlHelper.ExecuteNonQuery(trans, CommandType.Text, strSql, sqlParams);


                        string strContent = string.Format("机组【{0}】 由【{1}】交路 更改为【{2}】交路", LCGroup.GetGroupString(group), InParams.SrcJiaolu.jiaoluName, InParams.DestJiaolu.jiaoluName);

                        LCGroup.SaveNameplateLog(group, InParams.SrcJiaolu, InParams.DutyUser, LBoardChangeType.btcChangeJiaoLu, strContent);

                        output.result = 0;
                        trans.Commit();
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw ex;
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                output.resultStr = ex.Message.ToString();
                output.result    = 1;
            }


            return(output);
        }
コード例 #2
0
        public InterfaceOutPut ChangeJiaoLu(string data)
        {
            InterfaceOutPut      output = new InterfaceOutPut();
            JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();

            Group group = new Group();

            try
            {
                ChangeGrpJlParam InParams = javaScriptSerializer.Deserialize <ChangeGrpJlParam>(data);
                if (!LCGroup.GetGroup(InParams.GroupGUID, group))
                {
                    throw new Exception("没有找到对应的机组");
                }
                if (!string.IsNullOrEmpty(group.trainPlanID))
                {
                    throw new Exception("该机组已按排计划,不能修改所属交路");
                }

                SqlParameter[] sqlParams = new SqlParameter[] {
                    new SqlParameter("strGroupGUID", InParams.GroupGUID),
                    new SqlParameter("DestJiaoLu", InParams.DestJiaolu.jiaoluID),
                    new SqlParameter("Checi1", InParams.CheCi1),
                    new SqlParameter("Checi2", InParams.CheCi2),
                    new SqlParameter("NewCheCiGUID", Guid.NewGuid())
                };

                string strSql = "select ISNULL(max(nCheciOrder),1) from TAB_Nameplate_TrainmanJiaolu_Named where strTrainmanJiaoluGUID = @DestJiaoLu";

                int nOrder = Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.ConnString, CommandType.Text, strSql, sqlParams));

                nOrder++;
                SqlConnection conn = new SqlConnection(SqlHelper.ConnString);
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        switch (InParams.SrcJiaolu.jiaoluType)
                        {
                        //记名式
                        case 2:
                        {
                            break;
                        }

                        //轮乘
                        case 3:
                        {
                            strSql = "delete from TAB_Nameplate_TrainmanJiaolu_Order where strGroupGUID = @strGroupGUID";
                            SqlHelper.ExecuteNonQuery(trans, CommandType.Text, strSql, sqlParams);
                            break;
                        }

                        //包乘
                        case 4:
                        {
                            strSql = "delete from TAB_Nameplate_TrainmanJiaolu_OrderInTrain where strGroupGUID = @strGroupGUID";
                            SqlHelper.ExecuteNonQuery(trans, CommandType.Text, strSql, sqlParams);
                            break;
                        }
                        }


                        //更新名牌关联交路
                        strSql = @"update TAB_Nameplate_TrainmanJiaolu_Named set strTrainmanJiaoluGUID = @DestJiaoLu,nCheciOrder = "
                                 + nOrder.ToString() +
                                 ",strCheCi1 = @Checi1,strCheCi2 = @Checi2 where  strGroupGUID = @strGroupGUID";

                        if (Convert.ToInt32(SqlHelper.ExecuteNonQuery(trans, CommandType.Text, strSql, sqlParams)) == 0)
                        {
                            //如果没有旧的机组,则重新插入记录
                            strSql = @"insert into TAB_Nameplate_TrainmanJiaolu_Named (strCheCiGUID,strTrainmanJiaoluGUID,nCheciOrder,nCheciType,strCheci1,strCheci2,strGroupGUID) 
                    values(@NewCheCiGUID,@DestJiaoLu,"
                                     + nOrder.ToString() +
                                     ",0,@Checi1,@Checi2,@strGroupGUID)";
                            SqlHelper.ExecuteNonQuery(trans, CommandType.Text, strSql, sqlParams);
                        }



                        //更新人员所属交路
                        strSql = @"update TAB_Org_Trainman set strTrainmanJiaoluGUID = @DestJiaoLu where strTrainmanGUID in (
                        select strTrainmanGUID1 from TAB_Nameplate_Group where strGroupGUID = @strGroupGUID
                        union
                        select strTrainmanGUID2 from TAB_Nameplate_Group where strGroupGUID = @strGroupGUID
                        union
                        select strTrainmanGUID3 from TAB_Nameplate_Group where strGroupGUID = @strGroupGUID
                        union
                        select strTrainmanGUID4 from TAB_Nameplate_Group where strGroupGUID = @strGroupGUID)";


                        SqlHelper.ExecuteNonQuery(trans, CommandType.Text, strSql, sqlParams);



                        string strContent = string.Format("机组【{0}】 由【{1}】交路 更改为【{2}】交路", LCGroup.GetGroupString(group), InParams.SrcJiaolu.jiaoluName, InParams.DestJiaolu.jiaoluName);

                        LCGroup.SaveNameplateLog(group, InParams.SrcJiaolu, InParams.DutyUser, LBoardChangeType.btcChangeJiaoLu, strContent);

                        output.result = 0;
                        trans.Commit();
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw ex;
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                output.resultStr = ex.Message.ToString();
                output.result    = 1;
            }


            return(output);
        }