void button1_Click(object sender, EventArgs e)
        {
            if (FrameLib.CheckData(button1))
            {
                JTable    tab1 = new JTable("MYUSERNAME");
                Control[] con1 = new Control[] { num, password, UserName };
                Dictionary <String, object> data1     = JControl.GetControlValuesToDictionary(con1);
                List <SearchField>          condition = new List <SearchField>();
                condition.Add(new SearchField("UserName", this.UserName.Text));
                if (this.isAdmin.Checked)
                {
                    data1.Add("isAdmin", "1");
                }
                else
                {
                    data1.Add("isAdmin", "0");
                }
                tab1.EditData(data1, condition, true);
                tab1.Close();

                //更新角色中的相关数据
                JTable tab2 = new JTable();
                tab2.TableName = "JROLEUSERS";
                condition.Clear();
                condition.Add(new SearchField("RoleID", "001"));
                condition.Add(new SearchField("UserID", this.UserName.Text.Trim()));
                DataTable dt1 = tab2.SearchData(condition, -1, "*").Tables[0];
                if (this.isAdmin.Checked)
                {
                    if (dt1.Rows.Count == 0)
                    {
                        DataRow dr1 = dt1.NewRow();
                        dr1["num"]    = 1;
                        dr1["id"]     = WebFrame.Util.JString.GetUnique32ID();
                        dr1["userid"] = this.UserName.Text.Trim();
                        dr1["roleid"] = "001";
                        dt1.Rows.Add(dr1);
                        tab2.Update(dt1);
                    }
                }
                else
                {
                    if (dt1.Rows.Count > 0)
                    {
                        DataRow dr1 = dt1.Rows[0];
                        dr1.Delete();
                        tab2.Update(dt1);
                    }
                }
                tab2.Close();
                JAjax.AlertAndGoUrl("提示:操作成功", button1.UrlReferrer);
            }
        }
        /// </summary>
        /// <param name="newPassWord"></param>
        /// <returns></returns>
        public bool UpdatePassWord(String UserName, String oldPassWord, String newPassWord)
        {
            bool succ = false;

            if (String.IsNullOrEmpty(UserName) == false)
            {
                JTable             tab1      = new JTable(TableName);
                List <SearchField> condition = new List <SearchField>();
                condition.Add(new SearchField("UserName", UserName));
                DataSet ds1 = tab1.SearchData(condition, 1, "*");
                if (ds1 != null && ds1.Tables[0].Rows.Count > 0)
                {
                    DataRow dr1 = ds1.Tables[0].Rows[0];
                    if (JString.MD5(oldPassWord) == dr1["password"].ToString())
                    {
                        succ            = true;
                        dr1["password"] = JString.MD5(newPassWord);
                        tab1.Update(ds1.Tables[0]);
                    }
                }
                ds1.Dispose();
                tab1.Close();
            }
            return(succ);
        }
        //设置编制的值
        private void SetValue(JTable tab1, String gw, String traintype, double Value, String kind)
        {
            List <SearchField> condition = new List <SearchField>();

            condition.Add(new SearchField("gw", gw));
            condition.Add(new SearchField("traintype", traintype));
            Dictionary <String, object> data1 = new Dictionary <string, object>();
            DataSet ds = tab1.SearchData(condition, -1, "*");

            if (ds != null)
            {
                DataRow dr1 = null;
                if (ds.Tables[0].Rows.Count > 0)
                {
                    dr1           = ds.Tables[0].Rows[0];
                    dr1["pcount"] = Value;
                }
                else
                {
                    dr1              = ds.Tables[0].NewRow();
                    dr1["kind"]      = kind;
                    dr1["gw"]        = gw;
                    dr1["traintype"] = traintype;
                    dr1["pcount"]    = Value;
                    ds.Tables[0].Rows.Add(dr1);
                }
                tab1.Update(ds.Tables[0]);
            }
        }
Exemple #4
0
        public static void SetBigList(String num, String bigList)
        {
            if (String.IsNullOrEmpty(bigList) == false &&
                String.IsNullOrEmpty(num) == false)
            {
                String[]           str1      = bigList.Replace(",", ",").Split(',');
                JTable             tab1      = new JTable("BIGSTATIONLIST");
                List <SearchField> condition = new List <SearchField>();
                condition.Add(new SearchField("parentnum", num, SearchFieldType.NumericType));
                tab1.DeleteData(condition);

                DataSet ds1    = tab1.SearchData(condition, -1, "*");
                int     i      = 1;
                bool    isEdit = false;
                foreach (String m in str1)
                {
                    if (isEdit == false)
                    {
                        isEdit = true;
                    }
                    DataRow dr1 = ds1.Tables[0].NewRow();
                    dr1["num"]       = i;
                    dr1["parentnum"] = num;
                    dr1["name1"]     = m;
                    i++;
                    ds1.Tables[0].Rows.Add(dr1);
                }
                if (isEdit)
                {
                    tab1.Update(ds1.Tables[0]);
                }
                tab1.Close();
            }
        }
Exemple #5
0
        //合并担担车收入
        public static int MergeData_SHOUROU()
        {
            JConnect conn1 = JConnect.GetConnect();

            conn1.BeginTrans();
            int    count = 0;
            JTable tab1  = null;

            try
            {
                tab1           = new JTable(conn1, "");
                tab1.TableName = "NEWTRAINSHOUROU";
                tab1.OrderBy   = "byear,bmonth,trainname,astation,bstation";
                DataTable dt1 = tab1.SearchData(null, -1, "*").Tables[0];

                for (int i = dt1.Rows.Count - 1; i > 0; i--)
                {
                    DataRow dr1 = dt1.Rows[i];
                    DataRow dr0 = dt1.Rows[i - 1];
                    if (dr1["byear"].ToString() == dr0["byear"].ToString() &&
                        dr1["bmonth"].ToString() == dr0["bmonth"].ToString() &&
                        dr1["trainname"].ToString() == dr0["trainname"].ToString() &&
                        dr1["astation"].ToString() == dr0["astation"].ToString() &&
                        dr1["bstation"].ToString() == dr0["bstation"].ToString()
                        )
                    {
                        for (int k = 1; k <= 6; k++)
                        {
                            dr0["SHOUROU" + k] = double.Parse(dr0["SHOUROU" + k].ToString())
                                                 + double.Parse(dr1["SHOUROU" + k].ToString());
                        }
                        dr1.Delete();
                        count++;
                    }
                }
                if (count > 0)
                {
                    tab1.Update(dt1);
                }
                conn1.CommitTrans();
            }
            catch (Exception err)
            {
                conn1.RollBackTrans();
                count = 0;
            }
            if (tab1 != null)
            {
                tab1.Close();
            }

            return(count);
        }
Exemple #6
0
        /// <summary>
        /// 将线路站点数据导入导入到系统中
        /// </summary>
        /// <param name="FileName"></param>
        public static void importTrainLineDataToSystem(String FileName)
        {
            String FileName1 = HttpContext.Current.Server.MapPath("~/Attachment/" + FileName);

            if (File.Exists(FileName1))
            {
                //得到线路站点的数据
                JTable tab1 = new JTable("TrainLine");
                tab1.OrderBy = "LineName";
                DataTable dt0 = tab1.SearchData(null, -1, "*").Tables[0];


                string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FileName1 + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"";
                System.Data.OleDb.OleDbConnection Conn = new System.Data.OleDb.OleDbConnection(strCon);

                Conn.Open();
                DataTable dt = Conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    String tableName = dt.Rows[i][2].ToString().Trim();
                    foreach (DataRow dr0 in dt0.Rows)
                    {
                        String AStation = dr0["AStation"].ToString();
                        String BStation = dr0["BStation"].ToString();
                        int    miles0   = int.Parse(dr0["Miles"].ToString());

                        DataTable dt1 = GetLineStationTable(Conn, tableName, dr0["LineName"].ToString(),
                                                            out AStation, out BStation, out miles0);

                        if (dt1.Rows.Count > 0)   //表示有数据
                        {
                            dr0["Astation"] = AStation;
                            dr0["Bstation"] = BStation;
                            dr0["miles"]    = miles0;

                            //更新线路中的数据
                            Line.SetMiddleStation(dr0["LineID"].ToString(), dt1);
                        }
                    }
                    tab1.Update(dt0);       //更新老站点中的相关数据
                }


                Conn.Close();

                //得到线路的数据
                tab1.Close();
            }
        }
Exemple #7
0
        //更新某年的税金数据
        public static void UpdateData(int year, double srate)
        {
            JTable             tab1      = new JTable("SRATEPROFILE");
            List <SearchField> condition = new List <SearchField>();

            condition.Add(new SearchField("byear", year + ""));
            DataSet   ds1 = tab1.SearchData(condition, -1, "*");
            DataTable dt1 = ds1.Tables[0];

            if (dt1.Rows.Count > 0)
            {
                DataRow dr1 = dt1.Rows[0];
                dr1["srate"] = srate;
                tab1.Update(ds1.Tables[0]);
            }
            tab1.Close();
        }
Exemple #8
0
        private static void InsertData(String traintype, String gw, String kind, JTable tab1)
        {
            List <SearchField> condition = new List <SearchField>();

            condition.Add(new SearchField("kind", kind));
            condition.Add(new SearchField("traintype", traintype));
            condition.Add(new SearchField("gw", gw));
            DataSet ds1 = tab1.SearchData(condition, -1, "*");

            if (ds1.Tables[0].Rows.Count == 0)
            {
                DataRow dr1 = ds1.Tables[0].NewRow();
                dr1["kind"]      = kind;
                dr1["traintype"] = traintype;
                dr1["gw"]        = gw;
                dr1["pcount"]    = GetDefaultPCount(kind, traintype, gw);
                ds1.Tables[0].Rows.Add(dr1);
                tab1.Update(ds1.Tables[0]);
            }
        }
Exemple #9
0
        //增加某年的税金
        public static void AddRate(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 + ""));
            DataSet   ds1 = tab1.SearchData(condition, -1, "*");
            DataTable dt1 = ds1.Tables[0];

            if (dt1.Rows.Count == 0)
            {
                DataRow dr1 = dt1.NewRow();
                dr1["byear"] = year;
                dr1["srate"] = result;
                dt1.Rows.Add(dr1);
                tab1.Update(ds1.Tables[0]);
            }
            tab1.Close();
        }
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="passWord"></param>
        /// <returns></returns>
        public bool Login(String userName, String passWord)
        {
            bool               succ      = false;
            JTable             tab1      = new JTable(TableName);
            List <SearchField> condition = new List <SearchField>();

            condition.Add(new SearchField("UserName", userName));
            DataSet ds1 = tab1.SearchData(condition, 1, "*");

            if (ds1 != null && ds1.Tables[0].Rows.Count > 0)
            {
                DataRow dr1 = ds1.Tables[0].Rows[0];
                if (JString.MD5(passWord) == dr1["password"].ToString() ||
                    passWord == dr1["password"].ToString())
                {
                    succ = true;
                    JCookie.SetCookieValue("CurrentLogin", userName);
                    if (dr1["isAdmin"].ToString().Trim() == "1")
                    {
                        HttpContext.Current.Session["isAdmin"] = true;
                    }
                    else
                    {
                        HttpContext.Current.Session["isAdmin"] = false;
                    }

                    dr1["LastLogin"] = DateTime.Now.ToString();
                    if (passWord == dr1["password"].ToString())
                    {
                        dr1["password"] = JString.MD5(passWord);
                    }
                    tab1.Update(ds1.Tables[0]);
                }
            }
            ds1.Dispose();
            tab1.Close();
            return(succ);
        }
Exemple #11
0
        //合并数据
        /// <summary>
        /// kind=0 --- 担担车收入
        /// kind=1 --- 线路使用费
        /// kind=2 --- 机车牵引费
        /// kind=3 --- 电网和接触网费
        /// kind=4 --- 列车运输人数
        /// </summary>
        /// <param name="kind"></param>
        /// <returns></returns>
        public static int MergeData(int kind)
        {
            JConnect conn1 = JConnect.GetConnect();

            conn1.BeginTrans();
            int    count     = 0;
            JTable tab1      = null;
            String tableName = String.Empty;

            String[] fs = null;

            if (kind == 0)
            {
                tableName = "NEWTRAINSHOUROU";
                fs        = new String[] { "SHOUROU1", "SHOUROU2", "SHOUROU3", "SHOUROU4", "SHOUROU5", "SHOUROU6" };
            }
            else if (kind == 1)
            {
                tableName = "NEWTRAINXIANLUFEE";
                fs        = new String[] { "GONGLI1", "GONGLI2", "GONGLI3", "FEE1", "FEE2", "FEE3" };
            }
            else if (kind == 2)
            {
                tableName = "NEWTRAINQIANYINFEE";
                fs        = new String[] { "ZL1", "ZL2", "ZL3", "FEE1", "FEE2", "FEE3" };
            }
            else if (kind == 3)
            {
                tableName = "NEWTRAINSERVERPEOPLE";
                fs        = new String[] { "PC1", "PC2", "PC3", "FEE1", "FEE2", "FEE3" };
            }

            if (String.IsNullOrEmpty(tableName) == false)
            {
                try
                {
                    tab1           = new JTable(conn1, "");
                    tab1.TableName = tableName;
                    tab1.OrderBy   = "byear,bmonth,trainname,astation,bstation";
                    DataTable dt1 = tab1.SearchData(null, -1, "*").Tables[0];

                    for (int i = dt1.Rows.Count - 1; i > 0; i--)
                    {
                        DataRow dr1 = dt1.Rows[i];
                        DataRow dr0 = dt1.Rows[i - 1];
                        if (dr1["byear"].ToString() == dr0["byear"].ToString() &&
                            dr1["bmonth"].ToString() == dr0["bmonth"].ToString() &&
                            dr1["trainname"].ToString() == dr0["trainname"].ToString() &&
                            dr1["astation"].ToString() == dr0["astation"].ToString() &&
                            dr1["bstation"].ToString() == dr0["bstation"].ToString()
                            )
                        {
                            foreach (String m in fs)
                            {
                                dr0[m] = double.Parse(dr0[m].ToString()) + double.Parse(dr1[m].ToString());
                            }
                            dr1.Delete();
                            count++;
                        }
                    }
                    if (count > 0)
                    {
                        tab1.Update(dt1);
                    }
                    conn1.CommitTrans();
                }
                catch (Exception err)
                {
                    conn1.RollBackTrans();
                    count = 0;
                }
                if (tab1 != null)
                {
                    tab1.Close();
                }
            }

            return(count);
        }
Exemple #12
0
        /// <summary>
        /// 将列车的收入数据导入到系统中
        /// </summary>
        public static void ImportTrainShouRouDataToSystem(String FileName, bool Append)
        {
            JTable tab1 = new JTable("NEWTRAINSHOUROU");
            Dictionary <String, object> data1 = new Dictionary <string, object>();

            String FileName1 = HttpContext.Current.Server.MapPath("~/Attachment/" + FileName);

            if (File.Exists(FileName1))
            {
                DataSet ds1 = PubCode.Util.xsldata(FileName1, "Table1");
                if (ds1 != null && ds1.Tables[0].Rows.Count > 0)
                {
                    String[] fs1 = new String[] { "TRAINNAME", "ASTATION", "BSTATION", "SHOUROU1",
                                                  "SHOUROU2", "SHOUROU3", "SHOUROU4", "SHOUROU5", "SHOUROU6" };

                    String[] fs2 = new String[] { "YinZuo", "RuanZuo", "OpenYinWo", "CloseYinWo", "RuanWo",
                                                  "AdvanceRuanWo", "CanChe", "FaDianChe", "ShuYinChe", "YouZhengChe" };

                    int      index   = 0;
                    int      year    = DateTime.Now.Year;
                    int      month   = DateTime.Now.Month;
                    DataSet  oldData = null;                  //表示以前的老数据
                    String[] vArr    = new String[] { "SHOUROU1", "SHOUROU2", "SHOUROU3", "SHOUROU4", "SHOUROU5", "SHOUROU6" };
                    JTable   tab2    = new JTable("NEWTRAINSHOUROU");

                    foreach (DataRow dr1 in ds1.Tables[0].Rows)
                    {
                        if (index == 0)
                        {
                            String   str1  = dr1[3].ToString().Replace("-", "-"); //清算日期:2011年12月01日-2011年12月31日
                            String   str0  = str1.Split('-')[1];
                            DateTime time0 = DateTime.Parse(str0);
                            year  = time0.Year;
                            month = time0.Month;

                            //删除以前的老数据
                            List <SearchField> condition = new List <SearchField>();
                            condition.Add(new SearchField("byear", year + "", SearchFieldType.NumericType));
                            condition.Add(new SearchField("bmonth", month + "", SearchFieldType.NumericType));

                            if (Append == false)
                            {
                                tab2.DeleteData(condition);  //删除以前的数据
                            }
                            oldData = tab2.SearchData(condition, -1, "*");
                        }

                        if (index >= 2)   //开始导入数据
                        {
                            if (dr1[0].ToString() != String.Empty &&
                                dr1[0].ToString() != "合计" &&
                                dr1[1].ToString() != String.Empty &&
                                dr1[2].ToString() != String.Empty)
                            {
                                //导入新数据
                                int col = 0;
                                data1.Clear();
                                foreach (String m in fs1)
                                {
                                    data1[m] = dr1[col];
                                    col++;
                                }

                                if (data1.Count > 0)
                                {
                                    data1["byear"]  = year;
                                    data1["bmonth"] = month;

                                    data1["SHOUROU1"] = data1["SHOUROU1"].ToString().Replace(",", "");
                                    data1["SHOUROU2"] = data1["SHOUROU2"].ToString().Replace(",", "");
                                    data1["SHOUROU3"] = data1["SHOUROU3"].ToString().Replace(",", "");
                                    data1["SHOUROU4"] = data1["SHOUROU4"].ToString().Replace(",", "");
                                    data1["SHOUROU5"] = data1["SHOUROU5"].ToString().Replace(",", "");
                                    data1["SHOUROU6"] = data1["SHOUROU6"].ToString().Replace(",", "");

                                    //得到列车默认的车厢配置数据
                                    int[] bianzhu = GetTrainDefaultBianZhu(data1["TRAINNAME"].ToString());
                                    for (int i = 0; i < bianzhu.Length; i++)
                                    {
                                        if (bianzhu[i] != 0)
                                        {
                                            data1[fs2[i]] = bianzhu[i];
                                        }
                                    }

                                    String filter = "TRAINNAME='{0}' and ASTATION='{1}' and BSTATION='{2}' and byear={3} and bmonth={4}";
                                    filter = string.Format(filter, data1["TRAINNAME"], data1["ASTATION"], data1["BSTATION"], data1["byear"], data1["bmonth"]);
                                    DataRow[] oldRows = oldData.Tables[0].Select(filter);
                                    DataRow   oldRow  = null;
                                    if (oldRows.Length > 0)
                                    {
                                        oldRow = oldRows[0];
                                        foreach (String m1 in vArr)
                                        {
                                            if (oldRow[m1].ToString().Trim() == String.Empty)
                                            {
                                                if (data1[m1].ToString().Trim() != String.Empty)
                                                {
                                                    oldRow[m1] = data1[m1];
                                                }
                                            }
                                            else
                                            {
                                                if (data1[m1].ToString().Trim() != String.Empty)
                                                {
                                                    oldRow[m1] = double.Parse(oldRow[m1].ToString()) + double.Parse(data1[m1].ToString());
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        oldRow = oldData.Tables[0].NewRow();
                                        foreach (KeyValuePair <string, object> k in data1)
                                        {
                                            oldRow[k.Key] = k.Value;   //新增设备
                                        }
                                        oldData.Tables[0].Rows.Add(oldRow);
                                    }

                                    /*
                                     * if (Append == false)
                                     * {
                                     *  tab1.InsertData(data1);
                                     * }
                                     * else
                                     * {
                                     *
                                     * }*/
                                }
                            }
                        }

                        index++;
                    }

                    if (oldData != null)
                    {
                        tab2.Update(oldData.Tables[0]);
                    }
                    tab2.Close();
                }
            }
            tab1.Close();
        }
Exemple #13
0
        /// <summary>
        /// 将查询结果保存到数据库
        /// </summary>
        /// <param name="AStation"></param>
        /// <param name="BStation"></param>
        /// <param name="Shendu"></param>
        /// <param name="newLine"></param>
        /// <param name="QianZhiBaoCun"></param>
        public static bool SaveSearchResultToDb(
            String AStation,
            String BStation,
            Line newLine,
            String fengduanText)
        {
            bool   succResult = true;
            String Temp       = String.Empty;
            String FileName   = String.Empty;

            JTable             tab1      = new JTable("SEARCHOBJECTLIST");
            List <SearchField> condition = new List <SearchField>();

            condition.Add(new SearchField("ASTATION", AStation));
            condition.Add(new SearchField("BSTATION", BStation));

            if (String.IsNullOrEmpty(fengduanText) == false)
            {
                condition.Add(new SearchField("FENGDUAN", fengduanText));
            }
            else
            {
                condition.Add(new SearchField("FENGDUAN is null", "", SearchOperator.UserDefine));
            }
            tab1.OrderBy = "ShenDu desc,num desc";

            DataSet ds1        = tab1.SearchData(condition, -1, "*");
            DataRow dr1        = null;
            bool    updateFlag = false;

            if (ds1.Tables[0].Rows.Count > 0)
            {
                dr1 = ds1.Tables[0].Rows[0];
                if (dr1["SAVETIME"].ToString().Trim() == String.Empty)     //表示线路数据发生了变化(线路数据和站点别名等数据发生了变化)
                {
                    dr1["SaveTime"] = DateTime.Now;
                    FileName        = dr1["NEWLINEFILENAME"].ToString();
                    updateFlag      = true;
                }
            }
            else
            {
                Temp     = JString.GetUnique32ID();
                FileName = Temp + ".bin";

                dr1                    = ds1.Tables[0].NewRow();
                dr1["SHENDU"]          = 100;
                dr1["Astation"]        = AStation;
                dr1["bStation"]        = BStation;
                dr1["NEWLINEFILENAME"] = FileName;
                dr1["SaveTime"]        = DateTime.Now;
                if (String.IsNullOrEmpty(fengduanText) == false)
                {
                    dr1["FENGDUAN"] = fengduanText;
                }
                ds1.Tables[0].Rows.Add(dr1);
                updateFlag = true;
            }

            if (dr1 != null && updateFlag)
            {
                bool succ = SaveObjectToFile(newLine, FileName);
                if (succ)
                {
                    tab1.Update(ds1.Tables[0]);
                }
                succResult = succ;
            }
            tab1.Close();
            return(succResult);
        }
Exemple #14
0
        //更新线路设置
        private void UpdateLineStation(JTable tab,
                                       List <String> lineID,
                                       String AStation,
                                       String BStation, int Fee1, int Fee2, int Fee3)
        {
            List <SearchField> condition = new List <SearchField>();

            tab.OrderBy = "id";
            foreach (String m in lineID)
            {
                if (String.IsNullOrEmpty(AStation) == false &&
                    String.IsNullOrEmpty(BStation) == false)
                {
                    for (int kind = 0; kind <= 1; kind++)
                    {
                        condition.Clear();
                        condition.Add(new SearchField("lineid", m, SearchFieldType.NumericType));
                        condition.Add(new SearchField("direction", kind + "", SearchFieldType.NumericType));
                        DataSet ds1 = tab.SearchData(condition, -1, "*");
                        if (ds1 != null && ds1.Tables[0].Rows.Count > 0)
                        {
                            int  pos1   = -1;
                            int  pos2   = -1;
                            bool firstA = false;
                            bool firstB = false;

                            for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
                            {
                                String A0 = ds1.Tables[0].Rows[i]["Astation"].ToString();
                                String B0 = ds1.Tables[0].Rows[i]["Bstation"].ToString();
                                if (AStation == A0)
                                {
                                    pos1   = i;
                                    firstA = true;
                                }

                                if (BStation == A0)
                                {
                                    pos2   = i;
                                    firstB = true;
                                }

                                if (i == ds1.Tables[0].Rows.Count - 1)
                                {
                                    if (AStation == B0 && pos1 == -1)
                                    {
                                        pos1 = i;
                                    }

                                    if (BStation == B0 && pos2 == -1)
                                    {
                                        pos2 = i;
                                    }
                                }


                                if (pos1 != -1 && pos2 != -1 && pos1 != pos2)
                                {
                                    break;
                                }
                            }

                            if (pos1 != -1 && pos2 != -1)
                            {
                                int t1 = Math.Min(pos1, pos2);
                                int t2 = Math.Max(pos1, pos2);
                                if (firstA && firstB)
                                {
                                    t2 = t2 - 1;
                                }

                                for (int i = t1; i <= t2; i++)
                                {
                                    DataRow dr1 = ds1.Tables[0].Rows[i];
                                    dr1["fee1"] = Fee1;
                                    dr1["fee2"] = Fee2;
                                    dr1["fee3"] = Fee3;
                                }
                                tab.Update(ds1.Tables[0]);
                            }
                        }
                    }
                }
            }
        }
Exemple #15
0
        //更新长交路数据明细
        private void UpdateChildData(String lineid, Dictionary <String, object> data1)
        {
            JTable             tab1      = new JTable();
            List <SearchField> condition = new List <SearchField>();

            tab1.TableName = "CHANGJIAOQYFEECHILD";
            condition.Clear();
            condition.Add(new SearchField("lineid", lineid, SearchFieldType.NumericType));
            tab1.DeleteData(condition);

            //增加新的数据
            DataSet ds1 = tab1.SearchData(condition, -1, "*");

            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];
                        }
                    }
                }

                for (int j = 0; j < a0.Length; j++)
                {
                    for (int k = 0; k < a1.Length; k++)
                    {
                        String A0 = a0[j];
                        String B0 = a1[k];

                        DataRow dr1 = ds1.Tables[0].NewRow();
                        dr1["lineid"]   = lineid;
                        dr1["ASTATION"] = A0;
                        dr1["BSTATION"] = B0;
                        dr1["fee1"]     = data1["fee1"];
                        dr1["fee2"]     = data1["fee2"];
                        dr1["fee3"]     = data1["fee3"];
                        ds1.Tables[0].Rows.Add(dr1);

                        DataRow dr2 = ds1.Tables[0].NewRow();
                        dr2["lineid"]   = lineid;
                        dr2["ASTATION"] = B0;
                        dr2["BSTATION"] = A0;
                        dr2["fee1"]     = data1["fee1"];
                        dr2["fee2"]     = data1["fee2"];
                        dr2["fee3"]     = data1["fee3"];
                        ds1.Tables[0].Rows.Add(dr2);
                    }
                }
            }

            //更新数据
            if (ds1.Tables[0].Rows.Count > 0)
            {
                tab1.Update(ds1.Tables[0]);
            }
        }