Ejemplo n.º 1
0
        /// <summary>
        /// 得到某年的税金
        /// </summary>
        /// <param name="year"></param>
        /// <returns></returns>
        public static double GetRate(int year)
        {
            double result = 0.9676;
            JTable tab1   = new JTable("SRATEPROFILE");

            tab1.OrderBy = "byear desc";
            List <SearchField> condition = new List <SearchField>();

            condition.Add(new SearchField("byear", year + ""));
            DataRow dr1 = tab1.GetFirstDataRow(condition, "srate");

            if (dr1 != null)
            {
                result = double.Parse(dr1[0].ToString());
            }
            else
            {
                condition.Clear();
                dr1 = tab1.GetFirstDataRow(null, "srate");
                if (dr1 != null)
                {
                    result = double.Parse(dr1[0].ToString());
                }
            }
            tab1.Close();
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 得到动车的满员人数
        /// </summary>
        /// <returns></returns>
        private int GetTotalPersonForHighTrain()
        {
            int total = 0;

            if (this.TrainBigKind == ETrainBigKind.动车)
            {
                JTable             tab1      = new JTable("HighTrainProfile");
                List <SearchField> condition = new List <SearchField>();
                if (String.IsNullOrEmpty(this.TrainType) == false)
                {
                    condition.Add(new SearchField("HighTrainType", TrainType));
                }
                else
                {
                    condition.Add(new SearchField("HighTrainType", "-1"));
                }

                DataRow dr1 = tab1.GetFirstDataRow(condition, "*");
                if (dr1 != null)
                {
                    for (int i = 1; i <= 4; i++)
                    {
                        total = total + int.Parse(dr1["PCount" + i].ToString());
                    }
                }

                tab1.Close();
            }
            return(total);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 计算动车组的票价总收入
        /// </summary>
        /// <param name="HighTrainType"></param>
        /// <returns></returns>
        private double GetTotalShouruForHighTrain()
        {
            double Fee = 0;

            if (this.TrainBigKind == ETrainBigKind.动车)
            {
                JTable             tab1      = new JTable("HighTrainProfile");
                List <SearchField> condition = new List <SearchField>();
                if (String.IsNullOrEmpty(this.TrainType) == false)
                {
                    condition.Add(new SearchField("HighTrainType", TrainType));
                }
                else
                {
                    condition.Add(new SearchField("HighTrainType", "-1"));
                }

                DataRow dr1 = tab1.GetFirstDataRow(condition, "*");
                if (dr1 != null)
                {
                    for (int i = 1; i <= 4; i++)
                    {
                        Fee = Fee + this.YuXingLiCheng
                              * double.Parse(dr1["PCount" + i].ToString())
                              * double.Parse(dr1["Rate" + i].ToString());
                    }
                }

                tab1.Close();
            }
            return(Fee);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到加快的费率
        /// </summary>
        /// <param name="type1"></param>
        /// <returns></returns>
        private double GetJiaKuaiFeeByKind(ECommJiaKuai type1)
        {
            double             fee0      = 0;
            JTable             tab1      = new JTable("JiaKuaiProfile");
            List <SearchField> condition = new List <SearchField>();

            if (type1 == ECommJiaKuai.加快)
            {
                condition.Add(new SearchField("JiaKuaiType", "jk1"));
            }
            else if (type1 == ECommJiaKuai.特快)
            {
                condition.Add(new SearchField("JiaKuaiType", "jk2"));
            }
            else if (type1 == ECommJiaKuai.特快附加)
            {
                condition.Add(new SearchField("JiaKuaiType", "jk3"));
            }
            else
            {
                condition.Add(new SearchField("JiaKuaiType", "-1"));
            }
            DataRow dr1 = tab1.GetFirstDataRow(condition, "*");

            if (dr1 != null)
            {
                fee0 = double.Parse(dr1["Fee"].ToString());
            }
            tab1.Close();
            return(fee0);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 得到所有别名的List项
        /// </summary>
        /// <param name="A"></param>
        /// <returns></returns>
        public List <String> GetAlias(String A)
        {
            List <String> list0 = new List <string>();

            if (String.IsNullOrEmpty(A) == false)
            {
                JTable             tab1      = new JTable("TRAINALIAS");
                List <SearchField> condition = new List <SearchField>();
                condition.Add(new SearchField("TRAINNAME", A));
                DataRow dr1 = tab1.GetFirstDataRow(condition, " TRAINALIAS ");
                if (dr1 != null)
                {
                    String t1 = dr1[0].ToString();
                    if (String.IsNullOrEmpty(t1) == false)
                    {
                        String[] s1 = t1.Replace(",", ",").Split(',');
                        foreach (String m in s1)
                        {
                            if (list0.Contains(m) == false)
                            {
                                list0.Add(m);
                            }
                        }
                    }
                }
                tab1.Close();

                //把自己加入
                if (list0.Contains(A) == false)
                {
                    list0.Add(A);
                }
            }
            return(list0);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 得到下一个编号
        /// </summary>
        /// <returns></returns>
        public static int  GetNextNum(String TableName, String ColumnName)
        {
            int    result = 1;
            JTable tab1   = null;

            try
            {
                tab1 = new JTable(TableName);
                DataRow dr1 = tab1.GetFirstDataRow(null, "max(" + ColumnName + ") as max1");
                if (dr1 != null && dr1[0].ToString() != String.Empty)
                {
                    int.TryParse(dr1[0].ToString(), out result);
                    result++;
                }
            }
            catch (Exception err)
            {
                result = 1;
            }
            finally
            {
                if (tab1 != null)
                {
                    tab1.Close();
                }
            }

            return(result);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 得到满足条件的第一行数据
        /// </summary>
        /// <param name="condition">查询条件</param>
        /// <param name="Fields">数据字段</param>
        /// <returns>满足条件的行</returns>
        public DataRow  GetFirstDataRow(List <SearchField> condition, params String[] Fields)
        {
            JTable  tab1  = new JTable(daConnect, TableName);
            DataRow data1 = tab1.GetFirstDataRow(condition, Fields);

            tab1.Close();
            return(data1);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 得到下一个用户的编号
        /// </summary>
        /// <returns></returns>
        public int GetNextNum()
        {
            int     num1 = 1;
            JTable  tab1 = new JTable(this.daConnect, TableName);
            DataRow dr1  = tab1.GetFirstDataRow(null, "max(num)");

            if (dr1 != null && dr1[0].ToString() != String.Empty)
            {
                num1 = int.Parse(dr1[0].ToString()) + 1;
            }
            return(num1);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 得到动车的折扣计算
        /// </summary>
        /// <returns></returns>
        private static double GetDiscount(EHighTrainType trainType,
                                          TrainLine Line,
                                          int YunXingLiCheng)
        {
            double result   = 0;
            String RateName = String.Empty;

            //300公里的动车
            if (trainType == EHighTrainType.CRH2C ||
                trainType == EHighTrainType.CRH380A ||
                trainType == EHighTrainType.CRH380AL ||
                trainType == EHighTrainType.CRH380B ||
                trainType == EHighTrainType.CRH380BL)      //增加了动车车型的CRH380B和CRH380BL的处理
            {
                RateName = "Rate3";
            }
            else
            {
                RateName = "Rate2";
                if (Line != null)
                {
                    foreach (LineNode node1 in Line.Nodes)
                    {
                        int type1 = int.Parse(node1.LineType);
                        if (type1 > 2)
                        {
                            RateName = "Rate1";   //普通线路
                            break;
                        }
                    }
                }
            }

            //计算动车的折扣
            if (String.IsNullOrEmpty(RateName) == false)
            {
                JTable tab1 = new JTable("HIGHTRAINPRICERATE");
                tab1.OrderBy = "LICHENG desc";
                List <SearchField> condition = new List <SearchField>();
                condition.Add(new SearchField("LICHENG", YunXingLiCheng + "",
                                              SearchOperator.SmallerAndEqual, SearchFieldType.NumericType));
                DataRow dr1 = tab1.GetFirstDataRow(condition, RateName);
                if (dr1 != null)
                {
                    result = double.Parse(dr1[0].ToString());
                    result = result / 100d;
                }
                tab1.Close();
            }
            return(result);
        }
        //得到编制的值
        private double  GetValue(JTable tab1, String gw, String traintype)
        {
            double             result    = 0;
            List <SearchField> condition = new List <SearchField>();

            condition.Add(new SearchField("gw", gw));
            condition.Add(new SearchField("traintype", traintype));
            DataRow dr = tab1.GetFirstDataRow(condition, "pcount");

            if (dr != null)
            {
                result = double.Parse(dr[0].ToString());
            }
            return(result);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 得到不同车厢的重量配置
        /// </summary>
        /// <param name="type1"></param>
        /// <returns></returns>
        private static double GetCheXianWeight(ECommCheXian type1)
        {
            double             d1        = 0;
            JTable             tab1      = new JTable("CHEXIANWEIGHTPROFILE");
            List <SearchField> condition = new List <SearchField>();

            condition.Add(new SearchField("CHEXIANTYPE", (int)type1 + "", SearchFieldType.NumericType));
            DataRow dr1 = tab1.GetFirstDataRow(condition, "Weight");

            if (dr1 != null)
            {
                d1 = double.Parse(dr1[0].ToString());
            }
            tab1.Close();
            return(d1);
        }
Ejemplo n.º 12
0
        //得到下一个序号
        public static int GetNextNum()
        {
            int     result = 1;
            JTable  tab1   = new JTable("CHANGJIAOQYFEE");
            DataRow dr1    = tab1.GetFirstDataRow(null, "max(num)");

            if (dr1 != null)
            {
                if (dr1[0].ToString() != String.Empty)
                {
                    result = int.Parse(dr1[0].ToString()) + 1;
                }
            }
            tab1.Close();
            return(result);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 根据运行里程得到区段里程
        /// </summary>
        /// <param name="yuxinglicheng"></param>
        /// <returns></returns>
        private int GetQuDuanLiCheng(int yuXingLiCheng)
        {
            int    result = 0;
            JTable tab1   = null;

            try
            {
                tab1 = new JTable("LiChengProfile");
                List <SearchField> condition = new List <SearchField>();
                condition.Add(new SearchField("Pos1", yuXingLiCheng + "", SearchOperator.SmallerAndEqual, SearchFieldType.NumericType));
                condition.Add(new SearchField("(Pos2 >= " + yuXingLiCheng + " or Pos2 is null )", "", SearchOperator.UserDefine));
                tab1.OrderBy = "id";
                DataRow dr1 = tab1.GetFirstDataRow(condition, "*");
                if (dr1 != null)
                {
                    int pos1    = int.Parse(dr1["pos1"].ToString());
                    int posSize = int.Parse(dr1["posSize"].ToString());

                    int    y1 = (yuXingLiCheng - pos1 + 1) / posSize;
                    double t  = 0;
                    double y2 = (yuXingLiCheng - pos1 + 1 + t) / (posSize + t);
                    double y0 = y2 - y1;

                    if (y0 > 0 && y0 < 0.5)
                    {
                        y0 = 0.5;
                    }
                    else if (y0 >= 0.5)
                    {
                        y0 = 1.0;
                    }
                    else
                    {
                        y0 = 0;
                    }

                    result = (pos1 - 1) + (int)((y1 + y0) * posSize);
                }
            }
            finally
            {
                tab1.Close();
            }
            return(result);
        }
Ejemplo n.º 14
0
        public static void GetSearchInfoBynum(String num, out String A0, out String B0, out String ShenDu, out String Fengduan)
        {
            A0 = String.Empty; B0 = String.Empty; ShenDu = "30"; Fengduan = String.Empty;
            JTable             tab1      = new JTable("SEARCHOBJECTLIST");
            List <SearchField> condition = new List <SearchField>();

            condition.Add(new SearchField("num", num, SearchFieldType.NumericType));
            DataRow dr = tab1.GetFirstDataRow(condition, "*");

            if (dr != null)
            {
                A0       = dr["Astation"].ToString();
                B0       = dr["Bstation"].ToString();
                ShenDu   = dr["shendu"].ToString();
                Fengduan = dr["fengduan"].ToString();
            }
            tab1.Close();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 得到列车默认的车厢编组数据
        /// 规则:得到上次的编组数据,如果没有,从列车的数据中导入
        /// </summary>
        private static int[] GetTrainDefaultBianZhu(String TrainName)
        {
            int[]    bianzhu = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            String[] fs      = new String[] { "YinZuo", "RuanZuo", "OpenYinWo", "CloseYinWo", "RuanWo",
                                              "AdvanceRuanWo", "CanChe", "FaDianChe", "ShuYinChe", "YouZhengChe" };

            List <SearchField> condition = new List <SearchField>();

            condition.Add(new SearchField("TrainName", TrainName));
            JTable tab1 = new JTable();

            /*
             * tab1.TableName = "NEWTRAINSHOUROU";
             * tab1.OrderBy = "byear desc,bmonth desc";
             * DataRow dr1 = tab1.GetFirstDataRow(condition, "*"); */

            DataRow dr1 = null;

            if (dr1 == null ||
                dr1[0].ToString().Trim() == String.Empty)
            {
                tab1.TableName = "NEWTRAIN";
                tab1.OrderBy   = String.Empty;
                condition.Clear();
                condition.Add(new SearchField("instr(TrainName,'" + TrainName + "')>0", "", SearchOperator.UserDefine));
                dr1 = tab1.GetFirstDataRow(condition, "*");
            }
            if (dr1 != null)
            {
                for (int i = 0; i < bianzhu.Length; i++)
                {
                    if (dr1[fs[i]].ToString().Trim() != String.Empty)
                    {
                        bianzhu[i] = int.Parse(dr1[fs[i]].ToString().Trim());
                    }
                }
            }

            tab1.Close();
            return(bianzhu);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 得到牵引费
        /// 计算公式:合适的标准*列车的重量*运用的里程*2*365
        /// </summary>
        /// <returns></returns>
        public double GetQianYinCostOrDianFei()
        {
            double Fee = 0;

            if (this.TrainBigKind == ETrainBigKind.普通列车)
            {
                JTable             tab1      = new JTable("QIANYINFEEPROFILE");
                List <SearchField> condition = new List <SearchField>();
                condition.Add(new SearchField("QIANYINTYPE", (int)this.QianYinType + "", SearchFieldType.NumericType));
                DataRow dr1 = tab1.GetFirstDataRow(condition, "Fee1", "Fee2");
                if (dr1 != null)
                {
                    if (this.GongDianType == EGongDianType.直供电)
                    {
                        Fee = double.Parse(dr1["Fee1"].ToString());
                    }
                    else
                    {
                        Fee = double.Parse(dr1["Fee2"].ToString());
                    }
                }
                tab1.Close();
                Fee = Fee * this.GetTrainWeight() * this.YuXingLiCheng * 2 * 365; //合适的标准*列车的重量*运用的里程*2*365
            }
            else
            {
                int                lineid    = (int)this.TrainLine;
                JTable             tab1      = new JTable("TRAINLINEKINDPROFILE");
                List <SearchField> condition = new List <SearchField>();
                condition.Add(new SearchField("lineid", lineid + "", SearchFieldType.NumericType));
                DataRow dr1 = tab1.GetFirstDataRow(condition, "*");
                if (dr1 != null)
                {
                    Fee = Fee + (double.Parse(dr1["JIECHUFEE"].ToString()) + double.Parse(dr1["DIANFEE"].ToString()))
                          * this.YuXingLiCheng * this.GetTrainWeight();
                }
                tab1.Close();
            }
            return(Fee);
        }
Ejemplo n.º 17
0
        public static string GetIPs()
        {
            daConnect = JConnect.GetConnect();

            JTable tab1 = new JTable(daConnect, TableName);

            List <SearchField> condition = new List <SearchField>();

            condition.Add(new SearchField("STRID", "KIP"));
            bool    hasdata = tab1.HasData(condition);
            DataRow data1   = tab1.GetFirstDataRow(condition, "STRTEXT");

            tab1.Close();

            if (!hasdata)
            {
                return("");
            }
            else
            {
                return(data1["STRTEXT"].ToString().Trim());
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 根据列车名称得到列车对象
        /// </summary>
        /// <param name="TrainName"></param>
        /// <returns></returns>
        public static CommTrainBU GetTrainObjectByTrainName(String TrainName)
        {
            CommTrainBU obj1 = null;

            if (String.IsNullOrEmpty(TrainName) == false)
            {
                JTable             tab1      = new JTable("Train");
                List <SearchField> condition = new List <SearchField>();
                condition.Add(new SearchField("TrainName", TrainName));
                DataRow dr1 = tab1.GetFirstDataRow(condition, "*");
                if (dr1 != null)
                {
                    obj1               = new CommTrainBU();
                    obj1.Num           = dr1["num"].ToString();
                    obj1.TrainName     = dr1["TrainName"].ToString();
                    obj1.TrainBigKind  = (ETrainBigKind)(int.Parse(dr1["TrainBigKind"].ToString()));
                    obj1.TrainType     = dr1["TrainType"].ToString();
                    obj1.YuXingLiCheng = int.Parse(dr1["YuXingLiCheng"].ToString());

                    obj1.YinZuo        = int.Parse(dr1["YinZuo"].ToString());
                    obj1.RuanZuo       = int.Parse(dr1["RuanZuo"].ToString());
                    obj1.OpenYinWo     = int.Parse(dr1["OpenYinWo"].ToString());
                    obj1.CloseYinWo    = int.Parse(dr1["CloseYinWo"].ToString());
                    obj1.RuanWo        = int.Parse(dr1["RuanWo"].ToString());
                    obj1.AdvanceRuanWo = int.Parse(dr1["AdvanceRuanWo"].ToString());
                    obj1.CanChe        = int.Parse(dr1["CanChe"].ToString());
                    obj1.FaDianChe     = int.Parse(dr1["FaDianChe"].ToString());
                    obj1.ShuYinChe     = int.Parse(dr1["ShuYinChe"].ToString());

                    //车厢价格
                    obj1.YinZuoPrice        = int.Parse(dr1["YinZuoPrice"].ToString());
                    obj1.RuanZuoPrice       = int.Parse(dr1["RuanZuoPrice"].ToString());
                    obj1.OpenYinWoPrice     = int.Parse(dr1["OpenYinWoPrice"].ToString());
                    obj1.CloseYinWoPrice    = int.Parse(dr1["CloseYinWoPrice"].ToString());
                    obj1.RuanWoPrice        = int.Parse(dr1["RuanWoPrice"].ToString());
                    obj1.AdvanceRuanWoPrice = int.Parse(dr1["AdvanceRuanWoPrice"].ToString());
                    obj1.CanChePrice        = int.Parse(dr1["CanChePrice"].ToString());
                    obj1.FaDianChePrice     = int.Parse(dr1["FaDianChePrice"].ToString());
                    obj1.ShuYinChePrice     = int.Parse(dr1["ShuYinChePrice"].ToString());

                    obj1.JiaKuai = (ECommJiaKuai)(int.Parse(dr1["JiaKuai"].ToString()));
                    if (dr1["KongTiaoFee"].ToString().Trim() == "1")
                    {
                        obj1.KongTiaoFee = true;
                    }
                    else
                    {
                        obj1.KongTiaoFee = false;
                    }

                    obj1.XieBieZhengJiaFee = int.Parse(dr1["XieBieZhengJiaFee"].ToString());
                    obj1.QianYinType       = (EQianYinType)(int.Parse(dr1["QianYinType"].ToString()));
                    obj1.GongDianType      = (EGongDianType)(int.Parse(dr1["GongDianType"].ToString()));
                    obj1.WaterCount        = int.Parse(dr1["WaterCount"].ToString());
                    obj1.ServerPerson      = (EServerPerson)(int.Parse(dr1["ServerPerson"].ToString()));
                    obj1.RunHour           = int.Parse(dr1["RunHour"].ToString());

                    obj1.YongCheDiShu = double.Parse(dr1["YongCheDiShu"].ToString());
                    obj1.CheDiShu     = double.Parse(dr1["CheDiShu"].ToString());

                    obj1.Line0 = int.Parse(dr1["Line0"].ToString());
                    obj1.Line1 = int.Parse(dr1["Line1"].ToString());
                    obj1.Line2 = int.Parse(dr1["Line2"].ToString());
                    obj1.Line3 = int.Parse(dr1["Line3"].ToString());
                    obj1.Line4 = int.Parse(dr1["Line4"].ToString());
                    obj1.Line5 = int.Parse(dr1["Line5"].ToString());
                    obj1.Line6 = int.Parse(dr1["Line6"].ToString());
                    obj1.Line7 = int.Parse(dr1["Line7"].ToString());
                    obj1.Line8 = int.Parse(dr1["Line8"].ToString());

                    obj1.HighTrainBianZhu = (EHighTrainBianZhu)(int.Parse(dr1["HighTrainBianZhu"].ToString()));
                    obj1.HighTrainBigKind = (EHighTrainBigKind)(int.Parse(dr1["HighTrainBigKind"].ToString()));
                    obj1.CunZengMoShi     = (ECunZengMoShi)(int.Parse(dr1["CunZengMoShi"].ToString()));
                }
                tab1.Close();
            }
            return(obj1);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 获取指定运行里程下所有的票价信息
        /// </summary>
        /// <param name="Yxlc">运行里程</param>
        /// <returns></returns>
        public bool GetPriceInfo(int Yxlc, int trainType)
        {
            bool               result    = false;
            JTable             tab       = new JTable("TicketPrice");
            List <SearchField> condition = new List <SearchField>();

            condition.Add(new SearchField("StartMile", Yxlc.ToString(), SearchOperator.SmallerAndEqual, SearchFieldType.NumericType));
            condition.Add(new SearchField("EndMile", Yxlc.ToString(), SearchOperator.BiggerAndEqual, SearchFieldType.NumericType));
            condition.Add(new SearchField("TrainType", trainType.ToString(), SearchOperator.Equal, SearchFieldType.NumericType));

            DataRow dr  = tab.GetFirstDataRow(condition, new string[] { "*" });
            string  sql = tab.CommandText;

            if (dr != null)
            {
                if (!Convert.IsDBNull(dr["YZPrice"]) && dr["YZPrice"] != null)
                {
                    this.YZPrice = Convert.ToDouble(dr["YZPrice"]);
                }
                if (!Convert.IsDBNull(dr["RZPrice"]) && dr["RZPrice"] != null)
                {
                    this.RZPrice = Convert.ToDouble(dr["RZPrice"]);
                }
                if (!Convert.IsDBNull(dr["PTJKPrice"]) && dr["PTJKPrice"] != null)
                {
                    this.PTJKPrice = Convert.ToDouble(dr["PTJKPrice"]);
                }

                if (!Convert.IsDBNull(dr["KSJKPrice"]) && dr["KSJKPrice"] != null)
                {
                    this.KSJKPrice = Convert.ToDouble(dr["KSJKPrice"]);
                }

                if (!Convert.IsDBNull(dr["YWSPrice"]) && dr["YWSPrice"] != null)
                {
                    this.YWSPrice = Convert.ToDouble(dr["YWSPrice"]);
                }
                if (!Convert.IsDBNull(dr["YWZPrice"]) && dr["YWZPrice"] != null)
                {
                    this.YWZPrice = Convert.ToDouble(dr["YWZPrice"]);
                }
                if (!Convert.IsDBNull(dr["YWXPrice"]) && dr["YWXPrice"] != null)
                {
                    this.YWXPrice = Convert.ToDouble(dr["YWXPrice"]);
                }

                if (!Convert.IsDBNull(dr["RWSPrice"]) && dr["RWSPrice"] != null)
                {
                    this.RWSPrice = Convert.ToDouble(dr["RWSPrice"]);
                }

                if (!Convert.IsDBNull(dr["RWZPrice"]) && dr["RWZPrice"] != null)
                {
                    this.RWZPrice = Convert.ToDouble(dr["RWZPrice"]);
                }

                if (!Convert.IsDBNull(dr["RWXPrice"]) && dr["RWXPrice"] != null)
                {
                    this.RWXPrice = Convert.ToDouble(dr["RWXPrice"]);
                }

                if (!Convert.IsDBNull(dr["KDPrice"]) && dr["KDPrice"] != null)
                {
                    this.KDPrice = Convert.ToDouble(dr["KDPrice"]);
                }
                result = true;
            }
            else
            {
                result = false;//没有找到对应里程的数据
            }
            tab.Dispose();
            tab.Close();
            return(result);
        }
Ejemplo n.º 20
0
        //更新数据
        public bool UpdateData(Dictionary <String, object> data1)
        {
            bool result = false;
            List <SearchField> condition = new List <SearchField>();
            JTable             tab1      = new JTable();
            JTable             tab2      = new JTable();
            JTable             tab3      = new JTable("LineStation");

            try
            {
                tab1.MyConnect.BeginTrans();

                //更新CHANGJIAOQYFEE表中信息
                tab1.TableName = "CHANGJIAOQYFEE";
                String lineid = String.Empty;
                if (data1["lineid"] == null ||
                    data1["lineid"].ToString() == String.Empty ||
                    data1["lineid"].ToString() == "-1")
                {
                    data1.Remove("lineid");
                    tab1.InsertData(data1);

                    tab2.TableName = "CHANGJIAOQYFEE";
                    condition.Clear();
                    condition.Add(new SearchField("linename", data1["linename"].ToString().Trim()));
                    tab2.OrderBy = "lineid desc";
                    DataRow dr1 = tab2.GetFirstDataRow(condition, "lineid");
                    if (dr1 != null)
                    {
                        lineid = dr1["lineid"].ToString().Trim();
                    }
                    tab2.Close();
                }
                else
                {
                    lineid = data1["lineid"].ToString();
                    condition.Clear();
                    condition.Add(new SearchField("lineid", data1["lineid"].ToString().Trim(), SearchFieldType.NumericType));
                    tab1.EditData(data1, condition);
                }


                //更新LineStation中的相关数据
                if (String.IsNullOrEmpty(lineid) == false)
                {
                    //线路
                    String        error     = String.Empty;
                    String        lineName  = data1["linename"].ToString();
                    List <String> arrlineID = CheckLine(lineName, out error);
                    int           fee1      = int.Parse(data1["fee1"].ToString());
                    int           fee2      = int.Parse(data1["fee2"].ToString());
                    int           fee3      = 0;

                    if (String.IsNullOrEmpty(error))
                    {
                        Dictionary <String, object> data2 = new Dictionary <string, object>();
                        data2["checkflag"] = "1";
                        JTable tab4 = new JTable("CHANGJIAOQYFEE");
                        condition.Clear();
                        condition.Add(new SearchField("lineid", lineid, SearchFieldType.NumericType));
                        tab4.EditData(data2, condition);
                        tab4.Close();

                        //线路站点
                        String   jiaolu    = data1["jiaolu"].ToString();
                        String[] arrJiaolu = jiaolu.Replace("~", "-").Replace("~", "-").Replace("-", "-").Split('-');
                        for (int i = 0; i < arrJiaolu.Length - 1; i++)
                        {
                            //调整字符中的分隔符。
                            String[] a0 = arrJiaolu[i].Trim().Replace("、", ";").Replace(",", ";").Replace(",", ";").Replace(".", ";")
                                          .Replace("(", ";").Replace(")", "").Replace("(", ";").Replace(")", "").Split(';');
                            String[] a1 = arrJiaolu[i + 1].Trim().Replace("、", ";").Replace(",", ";").Replace(",", ";").Replace(".", ";")
                                          .Replace("(", ";").Replace(")", "").Replace("(", ";").Replace(")", "").Split(';');

                            for (int j = 0; j < a0.Length; j++)
                            {
                                a0[j] = a0[j].Trim();
                                if (j > 0)
                                {
                                    if (a0[j] == "东" || a0[j] == "南" || a0[j] == "西" || a0[j] == "北")
                                    {
                                        a0[j] = a0[j - 1] + a0[j];
                                    }
                                }
                            }

                            for (int j = 0; j < a1.Length; j++)
                            {
                                a1[j] = a1[j].Trim();
                                if (j > 0)
                                {
                                    if (a1[j] == "东" || a1[j] == "南" || a1[j] == "西" || a1[j] == "北")
                                    {
                                        a1[j] = a1[j - 1] + a1[j];
                                    }
                                }
                            }

                            //提交数据更新
                            foreach (String Astation in a0)
                            {
                                foreach (String Bstation in a1)
                                {
                                    UpdateLineStation(tab3, arrlineID, Astation, Bstation, fee1, fee2, fee3);
                                }
                            }
                        }
                    }
                    else
                    {
                        JAjax.Alert(error);
                    }
                }

                //提交事务处理
                tab1.MyConnect.CommitTrans();
                result = true;
            }
            catch (Exception err)
            {
                tab1.MyConnect.RollBackTrans();
                ;
            }

            tab1.Close();
            tab2.Close();
            tab3.Close();
            return(result);
        }