Esempio n. 1
0
        /// <summary>
        /// 功能:插入一条数据
        /// <param name="data1">要插入的数据</param>
        /// </summary>
        public void InsertData(Dictionary <string, object> data1)
        {
            JTable tab1 = new JTable(TableName);

            tab1.InsertData(data1);
            tab1.Close();
        }
Esempio n. 2
0
        /// <summary>
        /// 将视图状态中的数据进行提交
        /// 1、判断是否有删除的数据,如果有,则删除
        /// 2、判断是否有新增的数据,如果有,则新增
        /// 3、剔除PARENTGUID为-1的数据
        /// </summary>
        public void Submit()
        {
            DataTable                   dt1       = this.AttachmentList;
            JTable                      tab1      = new JTable(this.TableName);
            List <SearchField>          condition = new List <SearchField>();
            Dictionary <String, object> dic1      = new Dictionary <string, object>();

            foreach (DataRow dr1 in dt1.Rows)
            {
                if (dr1["PARENTGUID"].ToString() != "-1")
                {
                    if (dr1["DataStatus"].ToString() == "deletedata")  //需要删除数据
                    {
                        //删除文件
                        if (String.IsNullOrEmpty(dr1["FILEDIR"].ToString()) == false &&
                            String.IsNullOrEmpty(dr1["ENCRYPTFILENAME"].ToString()) == false)
                        {
                            String fileName = dr1["FILEDIR"].ToString() + dr1["ENCRYPTFILENAME"].ToString();
                            fileName = Server.MapPath(fileName);
                            if (File.Exists(fileName))
                            {
                                File.Delete(fileName);
                            }
                        }

                        //删除数据库中的相关数据
                        condition.Clear();
                        condition.Add(new SearchField("GUIDID", dr1["GUIDID"].ToString()));
                        dic1.Clear();
                        dic1["DEL"] = "1";  //逻辑删除数据
                        tab1.EditData(dic1, condition);
                        //tab1.DeleteData(condition);
                    }

                    if (dr1["DataStatus"].ToString() == "newdata")  //表示新增数据
                    {
                        //将文件名改名,去掉$$符号
                        if (String.IsNullOrEmpty(dr1["FILEDIR"].ToString()) == false &&
                            String.IsNullOrEmpty(dr1["ENCRYPTFILENAME"].ToString()) == false)
                        {
                            String fileName  = dr1["FILEDIR"].ToString() + dr1["ENCRYPTFILENAME"].ToString();
                            String fileName1 = dr1["FILEDIR"].ToString() + dr1["ENCRYPTFILENAME"].ToString().Replace("$$", "");
                            fileName  = Server.MapPath(fileName);
                            fileName1 = Server.MapPath(fileName1);

                            File.Copy(fileName, fileName1);
                            File.Delete(fileName);
                        }

                        //更新数据中的数据
                        dic1.Clear();
                        dic1 = FrameLib.GetDictionaryByDataRow(dr1);
                        dic1["ENCRYPTFILENAME"] = dic1["ENCRYPTFILENAME"].ToString().Replace("$$", "");
                        dic1.Remove("DataStatus");
                        tab1.InsertData(dic1);
                    }
                }
            }
            tab1.Close();
        }
Esempio n. 3
0
        /// <summary>
        /// 新增一个实体数据
        /// </summary>
        /// <param name="data1">实体数据</param>
        public void NewData(JAuthorityDetailDD data1)
        {
            JTable tab1 = new JTable(daConnect, TableName);

            tab1.InsertData(data1);
            tab1.Close();
        }
Esempio n. 4
0
        /// <summary>
        /// 新增一个实体数据
        /// </summary>
        /// <param name="data1">实体数据</param>
        public void NewData(JModelDD data1)
        {
            JTable tab1 = new JTable(daConnect, TableName);

            tab1.InsertData(data1);
            tab1.Close();
        }
Esempio n. 5
0
        //更新列表数据
        public static void UpdateListData(DataTable dt1)
        {
            JTable tab1 = new JTable("TrainPerson");

            tab1.MyConnect.BeginTrans();
            try
            {
                List <SearchField> condition = new List <SearchField>();
                condition.Add(new SearchField("1=1", "", SearchOperator.UserDefine));
                tab1.DeleteData(condition);

                //插入新的数据
                Dictionary <String, object> data1 = new Dictionary <string, object>();
                foreach (DataRow dr1 in dt1.Rows)
                {
                    int pcount = int.Parse(dr1["pcount"].ToString());
                    if (pcount > 0)
                    {
                        data1.Clear();
                        data1["traintype"] = dr1["traintype"];
                        data1["kind"]      = dr1["kind"];
                        data1["gw"]        = dr1["gw"];
                        data1["pcount"]    = dr1["pcount"];
                        tab1.InsertData(data1);
                    }
                }
                tab1.MyConnect.CommitTrans();
            }
            catch
            {
                tab1.MyConnect.RollBackTrans();
            }
            tab1.Close();
        }
        /// <summary>
        /// 新增一个实体数据
        /// </summary>
        /// <param name="data1">实体数据</param>
        public void NewData(JUserActionLogDD data1)
        {
            JTable tab1 = new JTable(daConnect, TableName);

            tab1.InsertData(data1);
            tab1.Close();
        }
Esempio n. 7
0
        /// <summary>
        /// 新增一条数据
        /// </summary>
        /// <param name="data1">Dictionary数据</param>
        public void NewData(Dictionary <String, object> data1)
        {
            JTable tab1 = new JTable(daConnect, TableName);

            tab1.InsertData(data1);
            tab1.Close();
        }
        /// <summary>
        /// 新增一个实体数据
        /// </summary>
        /// <param name="data1">实体数据</param>
        public void NewData(Tb_PL_Month_DetailDD data1)
        {
            JTable tab1 = new JTable(daConnect, TableName);

            tab1.InsertData(data1);
            this.executeResultCount = tab1.ExecuteResultCount;
            tab1.Close();
        }
Esempio n. 9
0
        /// <summary>
        /// 新增一个实体数据
        /// </summary>
        /// <param name="data1">实体数据</param>
        public void NewData(Tb_KH_Project_PersonDD data1)
        {
            JTable tab1 = new JTable(daConnect, TableName);

            tab1.InsertData(data1);
            this.executeResultCount = tab1.ExecuteResultCount;
            tab1.Close();
        }
Esempio n. 10
0
        /// <summary>
        /// 新增一条数据
        /// </summary>
        /// <param name="data1">Dictionary数据</param>
        public void NewData(Dictionary <String, object> data1)
        {
            JTable tab1 = new JTable(daConnect, TableName);

            tab1.InsertData(data1);
            this.executeResultCount = tab1.ExecuteResultCount;
            tab1.Close();
        }
        /// <summary>
        /// 新增一个实体数据
        /// </summary>
        /// <param name="data1">实体数据</param>
        public void NewData(Tb_KaoHeZhiBiaoDD data1)
        {
            JTable tab1 = new JTable(daConnect, TableName);

            tab1.InsertData(data1);
            this.executeResultCount = tab1.ExecuteResultCount;
            tab1.Close();
        }
Esempio n. 12
0
        /// <summary>
        /// 新增一个实体数据
        /// </summary>
        /// <param name="data1">实体数据</param>
        public void NewData(Tb_WorkLogReadersDD data1)
        {
            JTable tab1 = new JTable(daConnect, TableName);

            tab1.InsertData(data1);
            this.executeResultCount = tab1.ExecuteResultCount;
            tab1.Close();
        }
        protected void ImportExcel(string FilePath, string SheetName)
        {
            JTable tab  = new JTable("NEWTRAIN");
            JTable tab1 = new JTable("NEWTRAIN");

            String FileName1 = HttpContext.Current.Server.MapPath(FilePath);

            if (File.Exists(FileName1))
            {
                DataSet                     ds1       = BusinessRule.PubCode.Util.xsldata(Server.MapPath(FilePath), SheetName);
                List <SearchField>          condition = new List <SearchField>();
                Dictionary <string, object> data      = new Dictionary <string, object>();
                if (ds1 != null && ds1.Tables[0].Rows.Count > 0)
                {
                    int      n   = ds1.Tables[0].Columns.Count;
                    JCommand cmd = new JCommand(JConnect.GetConnect());
                    cmd.CommandText = "select max(num) from NEWTRAIN";
                    int num = Convert.ToInt32(cmd.ExecuteScalar());
                    cmd.Close();
                    for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
                    {
                        condition.Clear();
                        condition.Add(new SearchField("TRAINNAME", ds1.Tables[0].Rows[i]["车次"].ToString()));
                        data.Clear();
                        data.Add("TRAINNAME", ds1.Tables[0].Rows[i]["车次"].ToString());
                        data.Add("ASTATION", ds1.Tables[0].Rows[i]["始发站"].ToString());
                        data.Add("BSTATION", ds1.Tables[0].Rows[i]["终到站"].ToString());
                        data.Add("TRAINBIGKIND", 0);
                        data.Add("TRAINTYPE", ds1.Tables[0].Rows[i]["列车类型"].ToString());
                        data.Add("MILE", ds1.Tables[0].Rows[i]["单程距离"].ToString());
                        data.Add("KXTS", ds1.Tables[0].Rows[i]["开行趟数"].ToString());
                        data.Add("CDZS", ds1.Tables[0].Rows[i]["车底组数"].ToString());
                        data.Add("YINZUO", ds1.Tables[0].Rows[i]["硬座"].ToString());
                        data.Add("RUANZUO", ds1.Tables[0].Rows[i]["软座"].ToString());
                        data.Add("OPENYINWO", ds1.Tables[0].Rows[i]["硬卧"].ToString());
                        data.Add("RUANWO", ds1.Tables[0].Rows[i]["软卧"].ToString());
                        data.Add("CANCHE", ds1.Tables[0].Rows[i]["餐车"].ToString());
                        data.Add("FADIANCHE", ds1.Tables[0].Rows[i]["发电车"].ToString());
                        data.Add("SHUYINCHE", ds1.Tables[0].Rows[i]["行李车"].ToString());
                        data.Add("YOUZHENGCHE", ds1.Tables[0].Rows[i]["邮政车"].ToString());
                        if (!tab1.HasData(condition))
                        {
                            data.Add("num", Convert.ToInt32(num) + 1);
                            tab.InsertData(data);
                            num++;
                        }
                        else
                        {
                            tab.EditData(data, condition);
                        }
                    }
                }
            }
            tab.Close();
            tab1.Close();
            WebFrame.Util.JAjax.Alert("导入完成!");
        }
Esempio n. 14
0
        /// <summary>
        /// 将列车现有的数据导入到XLS表中
        /// </summary>
        public static void ImportTrainDataToSystem(String FileName)
        {
            String[] fs = new String[] { "车次", "始发站", "终到站", "列车类型",
                                         "单程距离", "开行趟数", "车底组数", "硬座", "软座",
                                         "硬卧", "软卧", "餐车", "发电车", "行李车", "邮政车" };

            String[] fs1 = new String[] { "TRAINNAME", "ASTATION", "BSTATION", "TRAINTYPE",
                                          "MILE", "KXTS", "CDZS", "YINZUO", "RUANZUO", "OPENYINWO"
                                          , "RUANWO", "CANCHE", "FADIANCHE", "SHUYINCHE", "YOUZHENGCHE" };

            JTable tab1 = new JTable("NEWTRAIN");
            Dictionary <String, object> data1 = new Dictionary <string, object>();
            int num = 1;

            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)
                {
                    foreach (DataRow dr1 in ds1.Tables[0].Rows)
                    {
                        if (dr1["车次"].ToString().Trim() != String.Empty)
                        {
                            data1.Clear();
                            for (int i = 0; i < fs.Length; i++)
                            {
                                object obj1 = dr1[fs[i]];

                                data1.Add(fs1[i], obj1);
                            }
                            data1.Add("num", num);
                            data1.Add("TRAINBIGKIND", 0);
                            num++;
                            tab1.InsertData(data1);
                        }
                    }
                }
            }
            tab1.Close();
        }
Esempio n. 15
0
        /// <summary>
        /// 将客运机车牵引费导入到系统中
        /// </summary>
        /// <param name="FileName"></param>
        public static void ImportGTTrainDragFeeToSystem(String FileName)
        {
            String FileName1 = HttpContext.Current.Server.MapPath("~/Attachment/" + FileName);
            JTable tab1      = new JTable("GTTRAINDRAGFEE");
            Dictionary <String, object> data1 = new Dictionary <string, object>();

            String[] fs = new String[] { "线别", "交路", "机种", "牵引费", "接触网电费" };

            String[] fs1 = new String[] { "LINETYPE", "CROSSROAD", "MACTYPE", "DRAGFEE", "NETFEE" };


            if (File.Exists(FileName1))
            {
                DataSet ds1 = PubCode.Util.xsldata(FileName1, "Table1");
                if (ds1 != null && ds1.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr1 in ds1.Tables[0].Rows)
                    {
                        if (dr1["线别"].ToString().Trim() != String.Empty)
                        {
                            data1.Clear();
                            for (int i = 0; i < fs.Length; i++)
                            {
                                object obj1 = dr1[fs[i]];

                                data1.Add(fs1[i], obj1);
                            }
                            tab1.InsertData(data1);
                        }
                    }
                }

                //得到客专电费的数据
                tab1.Close();
            }
        }
Esempio n. 16
0
        /// <summary>
        /// 将客专公司电费导入到系统中
        /// </summary>
        /// <param name="FileName"></param>
        public static void ImportGSCorpElecFeeToSystem(String FileName)
        {
            String FileName1 = HttpContext.Current.Server.MapPath("~/Attachment/" + FileName);
            JTable tab1      = new JTable("GSCORPELECFEE");
            Dictionary <String, object> data1 = new Dictionary <string, object>();

            String[] fs = new String[] { "公司名称", "铁路局", "接触网使用费", "电费" };

            String[] fs1 = new String[] { "CORPNAME", "RWBUREAU", "NETFEE", "ELECFEE" };


            if (File.Exists(FileName1))
            {
                DataSet ds1 = PubCode.Util.xsldata(FileName1, "Table1");
                if (ds1 != null && ds1.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr1 in ds1.Tables[0].Rows)
                    {
                        if (dr1["公司名称"].ToString().Trim() != String.Empty)
                        {
                            data1.Clear();
                            for (int i = 0; i < fs.Length; i++)
                            {
                                object obj1 = dr1[fs[i]];

                                data1.Add(fs1[i], obj1);
                            }
                            tab1.InsertData(data1);
                        }
                    }
                }

                //得到客专电费的数据
                tab1.Close();
            }
        }
Esempio n. 17
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);
        }
Esempio n. 18
0
        protected void ImportExcel(string FilePath, string SheetName)
        {
            JTable tab  = new JTable("HIGHTRAINPROFILE");
            JTable tab1 = new JTable("HIGHTRAINPROFILE");

            String FileName1 = HttpContext.Current.Server.MapPath(FilePath);

            if (File.Exists(FileName1))
            {
                DataSet                     ds1       = BusinessRule.PubCode.Util.xsldata(Server.MapPath(FilePath), SheetName);
                List <SearchField>          condition = new List <SearchField>();
                Dictionary <string, object> data      = new Dictionary <string, object>();
                if (ds1 != null && ds1.Tables[0].Rows.Count > 0)
                {
                    int      n   = ds1.Tables[0].Columns.Count;
                    JCommand cmd = new JCommand(JConnect.GetConnect());
                    cmd.CommandText = "select max(id) from HIGHTRAINPROFILE";
                    int num = Convert.ToInt32(cmd.ExecuteScalar());
                    cmd.Close();
                    for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
                    {
                        condition.Clear();
                        condition.Add(new SearchField("HIGHTRAINTYPE", ds1.Tables[0].Rows[i]["动车类型"].ToString()));
                        data.Clear();
                        data.Add("HIGHTRAINTYPE", ds1.Tables[0].Rows[i]["动车类型"].ToString());
                        data.Add("MILETYPE", ds1.Tables[0].Rows[i]["动车类别"].ToString());
                        data.Add("RATE1", ds1.Tables[0].Rows[i]["一等座基本票价"].ToString());
                        data.Add("PCOUNT1", ds1.Tables[0].Rows[i]["一等座定员"].ToString());
                        data.Add("RATE2", ds1.Tables[0].Rows[i]["二等座基本票价"].ToString());
                        data.Add("PCOUNT2", ds1.Tables[0].Rows[i]["二等座定员"].ToString());
                        data.Add("RATE3", ds1.Tables[0].Rows[i]["动卧上铺基本票价"].ToString());
                        data.Add("RATE31", ds1.Tables[0].Rows[i]["动卧下铺基本票价"].ToString());
                        data.Add("PCOUNT3", ds1.Tables[0].Rows[i]["动卧定员"].ToString());
                        data.Add("RATE4", ds1.Tables[0].Rows[i]["商务座基本票价"].ToString());
                        data.Add("PCOUNT4", ds1.Tables[0].Rows[i]["商务座定员"].ToString());

                        if (!tab1.HasData(condition))
                        {
                            data.Add("id", Convert.ToInt32(num) + 1);
                            data.Add("SPEED", 0);
                            data.Add("PRICE", 0);
                            data.Add("COST1", 0);
                            data.Add("COST2", 0);
                            data.Add("COST3", 0);
                            data.Add("COST21", 0);
                            data.Add("COST22", 0);
                            data.Add("SPEED2", 0);
                            data.Add("SPEED3", 0);
                            tab.InsertData(data);
                            num++;
                        }
                        else
                        {
                            tab.EditData(data, condition);
                        }
                    }
                }
            }
            tab.Close();
            tab1.Close();
            WebFrame.Util.JAjax.Alert("导入完成!");
        }
        //导入数据
        void JButton2_Click(object sender, EventArgs e)
        {
            DataSet   ds = GetData();
            DataTable dt = ds.Tables[0];

            //导入数据
            Dictionary <String, object> data1 = new Dictionary <string, object>();
            JTable tab1 = new JTable("CHANGJIAOQYFEE");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                String lineType = "";
                String lineName = "";
                String qy       = "";
                String fee1     = "";
                String fee2     = "";
                String fee3     = "";

                DataRow dr = dt.Rows[i];
                //得到当前行的数据
                if (dr[0].ToString().Trim() != String.Empty)
                {
                    lineType = dr[0].ToString().Trim();
                    lineName = dr[1].ToString().Trim().Replace("~", "-");
                    qy       = dr[2].ToString().Trim();
                    if (qy == "内燃")
                    {
                        fee1 = dr[3].ToString().Trim();
                    }
                    else
                    {
                        fee2 = dr[3].ToString().Trim();
                    }
                    fee3 = dr[4].ToString().Trim();
                }

                if (lineType != String.Empty)
                {
                    //得到下一行的数据
                    if (i < dt.Rows.Count - 1)
                    {
                        DataRow dr1 = dt.Rows[i + 1];
                        if (dr1[0].ToString().Trim() == String.Empty)
                        {
                            qy = dr1[2].ToString().Trim();
                            if (qy == "内燃")
                            {
                                fee1 = dr1[3].ToString().Trim();
                            }
                            else
                            {
                                fee2 = dr1[3].ToString().Trim();
                            }
                        }
                    }
                }

                //验证数据是否正确
                if (String.IsNullOrEmpty(lineType) == false)
                {
                    data1.Clear();
                    data1["num"]      = BusinessRule.ChangJiaoFeeBU.GetNextNum();
                    data1["linename"] = lineType;
                    data1["jiaolu"]   = lineName;

                    if (fee1 != String.Empty)
                    {
                        data1["fee1"] = int.Parse(fee1);
                    }
                    else
                    {
                        data1["fee1"] = 0;
                    }

                    if (fee2 != String.Empty)
                    {
                        data1["fee2"] = int.Parse(fee2);
                    }
                    else
                    {
                        data1["fee2"] = 0;
                    }

                    if (fee3 != String.Empty)
                    {
                        data1["fee3"] = int.Parse(fee3);
                    }
                    else
                    {
                        data1["fee3"] = 0;
                    }
                    tab1.InsertData(data1);
                }
            }

            tab1.Close();   //关闭数据库的链接
            this.Repeater1.DataBind();
        }
Esempio n. 20
0
        /// <summary>
        /// 将列车的电费和接触网使用费导入到系统中
        /// </summary>
        public static void ImportTrainDianFeeToSystem(String FileName, bool Append)
        {
            JTable tab1 = new JTable("NewTrainDianFee");
            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", "ZL1",
                                                  "ZL2", "ZL3", "Fee1", "Fee2", "Fee3" };
                    int[] col = new int[] { 0, 1, 2, 3, 4, 5, 7, 8, 9 };


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

                            //删除以前的老数据
                            if (Append == false)
                            {
                                List <SearchField> condition = new List <SearchField>();
                                condition.Add(new SearchField("byear", year + "", SearchFieldType.NumericType));
                                condition.Add(new SearchField("bmonth", month + "", SearchFieldType.NumericType));
                                JTable tab2 = new JTable("NewTrainDianFee");
                                tab2.DeleteData(condition);
                                tab2.Close();
                            }
                        }

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

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

                                    for (int j = 3; j <= 8; j++)
                                    {
                                        data1[fs1[j]] = data1[fs1[j]].ToString().Replace(",", "");
                                        if (data1[fs1[j]].ToString().Trim() == "-")
                                        {
                                            data1[fs1[j]] = "0";
                                        }
                                    }

                                    tab1.InsertData(data1);
                                }
                            }
                        }

                        index++;
                    }
                }
            }
            tab1.Close();
        }