Exemple #1
0
        private void 导入TSLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show("使用方法:将tpr报表保存成txt文本文档后,导入即可!");
            string filename = "";

            try
            {
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter = "所有文件(*.*)|*.*|文本文件(*.txt)|*.txt|TPR报表文件(*.tpr)|*.tpr";
                string path = Application.StartupPath;
                if (!Directory.Exists(path + "\\Tpr"))
                {
                    Directory.CreateDirectory(path + "\\Tpr");
                }
                dlg.InitialDirectory = Application.StartupPath + "\\Tpr";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    filename = dlg.FileName;
                    MessageBox.Show
                        (GlobalApi.getOffice(dlg.FileName) + "\n" +
                        GlobalApi.getDateOfSale(dlg.FileName) + "\n" +
                        GlobalApi.getTotalTicket(dlg.FileName) + "张电子客票" + "\n" +
                        GlobalApi.getNORMALTICKETS(dlg.FileName)
                        );
                    GlobalApi.importAllLineFromTpr(dlg.FileName);
                    MessageBox.Show("导入完成" + filename);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + filename);
                GlobalApi.appenderrormessage(ex.Message + "导入失败" + filename);
            }
        }
Exemple #2
0
 private void 查询SToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (sr.ShowDialog() == DialogResult.OK)
         {
             display(sr.selString);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         GlobalApi.appenderrormessage("查询" + ex.Message);
     }
 }
Exemple #3
0
        public static void importEagleEasyReport(string filename)
        {
            string           eName = getTableNameOfExcel(filename);
            DataTable        dt    = new DataTable();
            OleDbDataAdapter adapt = new OleDbDataAdapter
                                         ("SELECT * FROM " + eName,
                                         "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename.Replace("/", "\\") + ";Extended Properties=Excel 8.0;");

            adapt.Fill(dt);
            string pnr = "";

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                try
                {
                    string newpnr = dt.Rows[i]["PNR"].ToString().Trim();
                    if (pnr == newpnr)
                    {
                        continue;
                    }
                    else
                    {
                        pnr = newpnr;
                    }
                    if (pnr.Length != 5)
                    {
                        continue;
                    }
                    string agentname   = dt.Rows[i][31].ToString().Trim();
                    string useraccount = dt.Rows[i][32].ToString().Trim();
                    string username    = dt.Rows[i][33].ToString().Trim();
                    string dateofsale  = dt.Rows[i][7].ToString().Trim();//"销售日期"
                    string cmdString   = string.Format
                                             ("update etickets set AGENTNAME='{0}',USERACCOUNT='{4}',USERNAME='******'"

                                             + " where PNR='{1}' and DATEOFSALE>=cdate('{2}') and DATEOFSALE<cdate('{3}')",
                                             agentname, pnr, dateofsale, DateTime.Parse(dateofsale).AddDays(3).ToShortDateString(),
                                             useraccount, username);
                    OleDbCommand cmd = new OleDbCommand(cmdString, GlobalVar.cn);
                    int          ups = cmd.ExecuteNonQuery();
                    GlobalApi.appenderrormessage("导入订单状态:PNR为" + pnr + "对应导入" + ups.ToString() + "张电子客票!");
                }
                catch
                {
                }
            }
        }
Exemple #4
0
 private void 导入ABMS报表ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         OpenFileDialog dlg = new OpenFileDialog();
         dlg.Filter = "EXCEL文件XLS格式(*.xls)|*.xls|EXCEL文件CSV格式(*.csv)|*.csv|所有文件(*.*)|*.*";
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             GlobalApi.importAbmsReport(dlg.FileName);
             MessageBox.Show("导入完成");
         }
     }
     catch (Exception ex)
     {
         //MessageBox.Show(ex.Message);
         GlobalApi.appenderrormessage(ex.Message);
     }
 }
Exemple #5
0
        private void 导入Eagle中文版订单报表ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string filename = "";

            try
            {
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter = "EXCEL文件XLS格式(*.xls)|*.xls|EXCEL文件CSV格式(*.csv)|*.csv|所有文件(*.*)|*.*";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    filename = dlg.FileName;
                    GlobalApi.importEagleEasyReport(dlg.FileName);
                    MessageBox.Show("导入Eagle订单状态完成");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "导入失败" + filename);
                GlobalApi.appenderrormessage(ex.Message + "导入Eagle订单状态失败" + filename);
            }
        }
Exemple #6
0
        private void 导入Eagle电子客票报表ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show("使用方法:从Eagle管理后台电子客票管理导出EXCEL的CSV文档转存成XLS文档后,导入即可!");
            string filename = "";

            try
            {
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter = "EXCEL文件XLS格式(*.xls)|*.xls|EXCEL文件CSV格式(*.csv)|*.csv|所有文件(*.*)|*.*";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    filename = dlg.FileName;
                    GlobalApi.importEagleReport(dlg.FileName);
                    MessageBox.Show("导入完成");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "导入失败" + filename);
                GlobalApi.appenderrormessage(ex.Message + "导入失败" + filename);
            }
        }
Exemple #7
0
        public static void importAllLineFromTpr(string filename)
        {
            GlobalVar.bModified = true;
            string content = GlobalApi.getTprContent(filename);

            string[] lines = content.Split('\n');
            GlobalVar.countStat = 0;
            for (int i = 0; i < lines.Length; i++)
            {
                try
                {
                    GlobalApi.importOneLineFromTpr(lines[i], filename);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            FormMain.LABEL.Text = string.Format("导入TPR报表完成");
            GlobalApi.appenderrormessage(string.Format("导入TPR报表完成,文件名为" + filename + "共{0}张电子客票", GlobalVar.countStat));
            GlobalVar.countStat = 0;
        }
Exemple #8
0
        private void 自动填入政策ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            zOther.PolicyDefaultSetup ds = new EagleFinance.zOther.PolicyDefaultSetup();
            if (ds.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            try
            {
                int netroute = 1;
                int rows     = dg.RowCount - 1;
                if (rows < 1)
                {
                    MessageBox.Show("请先执行查询", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                bool b高峰 = !GlobalApi.canStartGetPolicy();
                //if (b高峰) return;
                for (int i = 0; i < rows; i++)
                {
                    if (b高峰)
                    {
                        System.Threading.Thread.Sleep(3000);
                    }
                    LABEL.Text = "正在处理第" + i.ToString() + "/" + rows.ToString() + "条";

                    Application.DoEvents();
                    if (!ds.bReget)
                    {
                        if (dg.Rows[i].Cells[19].Value.ToString().Trim() != "")
                        {
                            continue;
                        }
                    }
                    string  id  = (dg.Rows[i].Cells[0].Value.ToString().Trim());
                    hashkey key = new hashkey();
                    key.username = dg.Rows[i].Cells[12].Value.ToString().Trim().ToUpper();                          //用户
                    key.flightno = dg.Rows[i].Cells[16].Value.ToString().Trim().Replace("/", " ").Trim().ToUpper(); //航班
                    try
                    {
                        key.date = dg.Rows[i].Cells[15].Value.ToString().Trim().ToUpper();//乘机日
                        key.date = DateTime.Now.Year.ToString() + "-" + key.date;
                        if (Math.Abs(DateTime.Parse(key.date).Month - DateTime.Now.Month) > 6)
                        {
                            key.date = DateTime.Parse(key.date).AddYears(1).ToShortDateString();
                        }
                    }
                    catch
                    {
                        GlobalApi.appenderrormessage("未取到航班日期!PNR = " + dg.Rows[i].Cells[9].Value.ToString().Trim().ToUpper());
                        continue;
                    }
                    key.bunk = dg.Rows[i].Cells[17].Value.ToString().Trim().ToUpper();//舱位
                    if (key.bunk.Length > 1)
                    {
                        GlobalApi.appenderrormessage("双航段,不能计算政策!PNR = " + dg.Rows[i].Cells[9].Value.ToString().Trim().ToUpper());
                        continue;
                    }
                    hashvalue value  = zOther.policyht.getvaluefromhashtable(key);
                    string    fromto = dg.Rows[i].Cells[18].Value.ToString().Trim().ToUpper();
                    if (value == null)
                    {
                        value = zOther.policyht.getvaluefromwebserverandsave(key, fromto.Substring(0, 3), fromto.Substring(3).Trim(), netroute);
                    }
                    if (value == null)
                    {
                        GlobalApi.appenderrormessage("计算政策失败!可能没有为该用户分配用户类别,PNR = "
                                                     + dg.Rows[i].Cells[9].Value.ToString().Trim().ToUpper());
                    }
                    else
                    {
                        try
                        {
                            string cmdString = string.Format
                                                   ("update etickets set [COMM]={0},[AGENTCOMM]={1}"
                                                   + " where [ID]={2}",
                                                   value.maxGain, value.userGain, id
                                                   );
                            OleDbCommand cmd = new OleDbCommand(cmdString, GlobalVar.cn);
                            cmd.ExecuteNonQuery();
                        }
                        catch
                        {
                            GlobalApi.appenderrormessage("更新时出错!PNR = " + dg.Rows[i].Cells[9].Value.ToString().Trim().ToUpper()
                                                         + "底价返点 = " + value.maxGain
                                                         + "代理返点 = " + value.userGain
                                                         );
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                GlobalApi.appenderrormessage("计算政策返点时错误:" + ex.Message);
            }
            LABEL.Text = "政策返点处理完毕!";
            MessageBox.Show("政策返点计算完毕!请重新查询!");
        }
Exemple #9
0
        int LP = 3;//底价点
        void export(List <int> rows)
        {
            Hashtable htColumn = new Hashtable();

            htColumn.Add(22, "底价金额");
            htColumn.Add(23, "返点金额");
            htColumn.Add(24, "利润");
            htColumn.Add(25, "实收");
            htColumn.Add(26, "备注");

            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter           = "Execl files (*.xls)|*.xls";
            saveFileDialog.FilterIndex      = 0;
            saveFileDialog.RestoreDirectory = true;
            saveFileDialog.CreatePrompt     = true;
            saveFileDialog.Title            = "导出Excel文件到";

            if (saveFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            Stream myStream;

            myStream = saveFileDialog.OpenFile();
            StreamWriter sw  = new StreamWriter(myStream, System.Text.Encoding.GetEncoding("gb2312"));
            string       str = "";

            //定义导出顺序!

            /*
             * int[] co = new int[dg.ColumnCount];
             * {
             *  for (int i = 0; i < co.Length; i++)
             *  {
             *      co[i] = i;
             *  }
             * }
             * *///rows里已经包含了顺序
            //导出顺序定义结束!
            try
            {
                //写标题
                /*for (int i = 0; i < dg.ColumnCount; i++)*/
                for (int i = 0; i < rows.Count; i++)
                {
                    /*if (!rows.Contains(i)) continue;*/
                    if (i > 0)
                    {
                        str += "\t";
                    }

                    int intColumn = rows[i];
                    if (intColumn > 20)
                    {
                        str += htColumn[intColumn].ToString();
                    }
                    else
                    {
                        /*str += dg.Columns[co[i]].HeaderText;*/
                        str += dg.Columns[intColumn].HeaderText;
                    }
                }
                if (str.Substring(0, 1) == "\t")
                {
                    str = str.Substring(1);
                }
                sw.WriteLine(str);
                //写内容
                for (int j = 0; j < dg.Rows.Count - 1; j++)
                {
                    FormMain.LABEL.Text = string.Format("正在导出报表,第{0}条,共{1}条", j, dg.Rows.Count);
                    Application.DoEvents();
                    string tempStr = "";
                    /*for (int k = 0; k < dg.Columns.Count; k++)*/
                    for (int k = 0; k < rows.Count; k++)
                    {
                        int intColumn = rows[k];
                        /*if (!rows.Contains(k)) continue;*///看是否选择了该列导出,未选择则继续下一列
                        if (k > 0)
                        {
                            tempStr += "\t";
                        }
                        try
                        {
                            //string temp = dg.Rows[j].Cells[co[k]].Value.ToString();
                            string temp = "NULL";
                            try
                            {
                                if (intColumn > 20)
                                {
                                    temp = "NULL";
                                }
                                else
                                {
                                    temp = dg.Rows[j].Cells[intColumn].Value.ToString();
                                }
                            }
                            catch
                            {
                                temp = "NULL";
                            }
                            if (rows[k] == 3 || rows[k] == 11 || rows[k] == 16)
                            {
                                try
                                {
                                    temp = DateTime.Parse(temp).ToShortDateString();
                                    if (rows[k] == 16)
                                    {
                                        temp = temp.Substring(5);
                                    }
                                }
                                catch
                                {
                                    temp = "NULL";
                                }
                            }
                            else if (rows[k] == 8)//第8列为总返点,导出到excel为3
                            {
                                try
                                {
                                    int value = int.Parse(temp);
                                    if (value >= LP)
                                    {
                                        temp = LP.ToString();
                                    }
                                }
                                catch
                                {
                                }
                            }
                            else if (intColumn == 22)//X值的金额
                            {
                                try
                                {
                                    float ftemp = float.Parse(dg.Rows[j].Cells[6].Value.ToString()) * (float)LP / 100F;
                                    temp = ftemp.ToString("f2");
                                }
                                catch
                                {
                                }
                            }
                            else if (rows[k] == 20)//第20列为代理返点,用第8列-3
                            {
                                try
                                {
                                    int tRet = int.Parse(dg.Rows[j].Cells[8].Value.ToString());
                                    if (tRet >= LP)
                                    {
                                        temp = string.Format("{0}", tRet - LP);
                                    }
                                    else
                                    {
                                        temp = "0";
                                    }
                                }
                                catch
                                {
                                }
                            }
                            else if (intColumn == 23)//Y值的金额
                            {
                                try
                                {
                                    int tRet = int.Parse(dg.Rows[j].Cells[8].Value.ToString());
                                    if (tRet >= LP)
                                    {
                                        tRet -= LP;
                                    }
                                    float ftemp = float.Parse(dg.Rows[j].Cells[6].Value.ToString())
                                                  * (float)tRet / 100F;
                                    temp = ftemp.ToString("f2");
                                }
                                catch
                                {
                                }
                            }
                            tempStr += temp;
                        }
                        catch (Exception ex)
                        {
                            //MessageBox.Show("次内部");
                            tempStr += "NULL";
                            if (j == dg.Rows.Count - 1)
                            {
                                ;
                            }
                            else
                            {
                                ;// throw new Exception(ex.ToString());
                            }
                        }
                    }
                    if (tempStr.Substring(0, 1) == "\t")
                    {
                        tempStr = tempStr.Substring(1);
                    }
                    sw.WriteLine(tempStr.Replace("\t\t", "\tNULL\t"));
                }
                sw.Close();
                myStream.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                GlobalApi.appenderrormessage(e.ToString());
            }
            finally
            {
                sw.Close();
                myStream.Close();
            }
        }
Exemple #10
0
        public static void importEagleReport(string filename)
        {
            GlobalVar.bModified = true;
            int              importSucc   = 0;
            string           theAgentName = "";
            string           eName        = getTableNameOfExcel(filename);
            DataTable        dt           = new DataTable();
            OleDbDataAdapter adapt        = new OleDbDataAdapter
                                                ("SELECT * FROM " + eName,
                                                "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename.Replace("/", "\\") + ";Extended Properties=Excel 8.0;");

            adapt.Fill(dt);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                try
                {
                    //if (i == 0) continue;
                    string temp = dt.Rows[i][2].ToString();
                    if (dt.Rows[i][2] == null || dt.Rows[i][2].ToString().Trim() == "")
                    {//第二列为空,则表示该行为代理商名称行
                        theAgentName = dt.Rows[i][0].ToString().Split(':')[0];
                        continue;
                    }
                    //用户	名称	操作时间	PNR	行程单号 脱机打印 电子票号	航班1	舱位1	航班2	舱位2	城市对1	城市对2	乘机日1	乘机日2	总价	客票状态	燃油	基建	票价

                    string receiptNumber = dt.Rows[i]["行程单号"].ToString().Trim();
                    string isOffline     = dt.Rows[i]["脱机打印"].ToString().Trim();
                    if (isOffline == "是")
                    {
                        isOffline = "1";
                    }
                    else
                    {
                        isOffline = "0";
                    }

                    string   useraccount  = dt.Rows[i]["用户"].ToString().Trim();
                    string   username     = dt.Rows[i]["名称"].ToString().Trim();
                    string   pnr          = dt.Rows[i]["PNR"].ToString().Trim();
                    string   dateofsale   = DateTime.Parse(dt.Rows[i]["操作时间"].ToString().Trim()).ToShortDateString();
                    string   etickets     = dt.Rows[i]["电子票号"].ToString().Trim();
                    string[] ets          = null;// etickets.Split(';');
                    string   flightnumber = dt.Rows[i]["航班1"].ToString().Trim()
                                            + (dt.Rows[i]["航班2"].ToString().Trim() == "VOID" ? "" : ("/" + dt.Rows[i]["航班2"].ToString().Trim()));
                    string flightbunk = dt.Rows[i]["舱位1"].ToString().Trim()
                                        + (dt.Rows[i]["舱位2"].ToString().Trim() == "" ? "" : ("/" + dt.Rows[i]["舱位2"].ToString().Trim()));
                    string flightcity = dt.Rows[i]["城市对1"].ToString().Trim()
                                        + (dt.Rows[i]["城市对2"].ToString().Trim() == "" ? "" : ("/" + dt.Rows[i]["城市对2"].ToString().Trim()));
                    string tt1 = dt.Rows[i]["乘机日1"].ToString().Trim();
                    string tt2 = dt.Rows[i]["乘机日2"].ToString().Trim();
                    try
                    {
                        tt1 = DateTime.Parse(tt1).ToShortDateString().Substring(5);
                        if (!(tt2 == "" || tt2 == null))
                        {
                            tt2 = DateTime.Parse(tt2).ToShortDateString().Substring(5);
                        }
                    }
                    catch
                    {
                    }
                    string flightdate = tt1
                                        + (tt2 == "" ? "" : ("/" + tt2));

                    if (etickets.Length > 0)
                    {
                        ets = etickets.Split(';');
                    }
                    //for (int j = 0; j < ets.Length; j++)//根据票号
                    {
                        //判断票号是否已经存在
                        {
                            //string cmdString = string.Format("select * from etickets where TKTNUMBER='{0}'", ets[j].Substring(4).Trim());
                            string cmdString = string.Format(
                                "select * from etickets where PNR='{0}' and DATEOFSALE>=cdate('{1}') and DATEOFSALE<cdate('{2}')",
                                pnr,
                                DateTime.Parse(dateofsale).AddDays(-1).ToShortDateString(),
                                DateTime.Parse(dateofsale).AddDays(2).ToShortDateString()
                                );
                            OleDbCommand     cmd     = new OleDbCommand(cmdString, GlobalVar.cn);
                            DataTable        dt1     = new DataTable();
                            OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
                            adapter.Fill(dt1);
                            if (dt1.Rows.Count < 1)
                            {
                                throw new Exception(dt1.Rows[i][3].ToString().Trim() + "票号未入库或者未从TPR报表中导入");
                            }
                        }
                        //更新表
                        {
                            FormMain.LABEL.Text = string.Format("正在导入Eagle报表{1}/{2}:票号{0}", etickets, importSucc, dt.Rows.Count);
                            Application.DoEvents();
                            //string cmdString = string.Format("update etickets set AGENTNAME='{0}',USERACCOUNT='{1}' where TKTNUMBER='{2}'",
                            //    theAgentName,
                            //    useraccount,
                            //    ets[j].Substring(4).Trim());
                            string cmdString = string.Format
                                                   ("update etickets set AGENTNAME='{0}',USERACCOUNT='{1}',"
                                                   + "FLIGHTNUMBER='{5}',FLIGHTBUNK='{6}',FLIGHTDATE='{7}',FLIGHTCITY='{8}',USERNAME='******',"
                                                   + "receiptNumber = '{10}', IsOffline = '{11}'"
                                                   + " where PNR='{2}' and DATEOFSALE>=cdate('{3}') and DATEOFSALE<=cdate('{4}')",
                                                   theAgentName,
                                                   useraccount,
                                                   pnr,
                                                   DateTime.Parse(dateofsale).AddDays(-3).ToShortDateString()
                                                   , DateTime.Parse(dateofsale).AddDays(2).ToShortDateString()
                                                   //5,6,7,8
                                                   , flightnumber, flightbunk, flightdate, flightcity, username, receiptNumber, isOffline
                                                   );
                            OleDbCommand cmd = new OleDbCommand(cmdString, GlobalVar.cn);
                            cmd.ExecuteNonQuery();
                            importSucc++;
                        }
                    }
                }
                catch (Exception ex)
                {
                    //MessageBox.Show(ex.Message);
                    GlobalApi.appenderrormessage(ex.Message);
                }
            }
            FormMain.LABEL.Text = string.Format("导入Eagle报表完成,共{0}张,其中成功导入{1}张    ", dt.Rows.Count, importSucc);
            GlobalApi.appenderrormessage(FormMain.LABEL.Text + filename);
        }
Exemple #11
0
        public static void importAbmsReport(string filename)
        {
            GlobalVar.bModified = true;
            int              importsucc = 0;
            string           eName      = getTableNameOfExcel(filename);
            DataTable        dt         = new DataTable();
            OleDbDataAdapter adapt      = new OleDbDataAdapter
                                              ("SELECT * FROM " + eName,
                                              "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename.Replace("/", "\\") + ";Extended Properties=Excel 8.0;");

            adapt.Fill(dt);
            string saleDate      = "";
            string username      = "";
            string useraccount   = "";
            string pnr           = "";
            string flightnumber  = "";
            string flightbunk    = "";
            string flightdate    = "";
            string flightcity    = "";
            string eticketnumber = "";

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                try
                {
                    string temp = dt.Rows[i][0].ToString();
                    if (temp != "")
                    {
                        saleDate = temp.Split(new string[] { "at" }, StringSplitOptions.RemoveEmptyEntries)[0];
                    }

                    temp = dt.Rows[i][1].ToString();
                    if (temp != "")
                    {
                        username = temp.Trim();
                    }

                    temp = dt.Rows[i][2].ToString();
                    if (temp != "")
                    {
                        useraccount = temp.Trim();
                    }

                    temp = dt.Rows[i][4].ToString();
                    if (temp != "")
                    {
                        pnr = temp.Trim();
                    }

                    temp = dt.Rows[i][5].ToString();
                    if (temp != "")
                    {
                        flightnumber = temp.Trim();
                    }
                    temp = dt.Rows[i][6].ToString();
                    if (temp != "")
                    {
                        flightbunk = temp.Trim();
                    }
                    temp = dt.Rows[i][7].ToString();
                    if (temp != "")
                    {
                        try { flightdate = DateTime.Parse(temp.Trim()).ToShortDateString().Substring(5); }
                        catch { flightdate = temp.Trim(); }
                    }
                    temp = dt.Rows[i][9].ToString();
                    if (temp != "")
                    {
                        flightcity = temp.Trim();
                    }
                    eticketnumber = dt.Rows[i][10].ToString().Trim();
                    //判断票号是否已经存在
                    {
                        //string cmdString = string.Format("select * from etickets where TKTNUMBER='{0}'", ets[j].Substring(4).Trim());
                        string cmdString = string.Format
                                               ("select * from etickets where PNR='{0}' and DATEOFSALE>=cdate('{1}') and DATEOFSALE<cdate('{2}')",
                                               pnr, saleDate, DateTime.Parse(saleDate).AddDays(1).ToShortDateString());
                        OleDbCommand     cmd     = new OleDbCommand(cmdString, GlobalVar.cn);
                        DataTable        dt1     = new DataTable();
                        OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
                        adapter.Fill(dt1);
                        if (dt1.Rows.Count < 1)
                        {
                            throw new Exception(dt1.Rows[i][3].ToString().Trim() + "票号未入库或者未从TPR报表中导入");
                        }
                    }
                    //更新表
                    {
                        FormMain.LABEL.Text = string.Format("正在导入ABMS报表{1}/{2}:票号{0}", eticketnumber, importsucc, dt.Rows.Count);
                        Application.DoEvents();
                        string cmdString = string.Format
                                               ("update etickets set USERNAME='******',USERACCOUNT='{1}',"
                                               + "FLIGHTNUMBER='{5}',FLIGHTBUNK='{6}',FLIGHTDATE='{7}',FLIGHTCITY='{8}'"
                                               + " where PNR='{2}' and DATEOFSALE>=cdate('{3}') and DATEOFSALE<cdate('{4}')",
                                               username,//theAgentName,
                                               useraccount,
                                               pnr, DateTime.Parse(saleDate).AddDays(-3).ToShortDateString()
                                               , DateTime.Parse(saleDate).AddDays(1).ToShortDateString()
                                               //5,6,7,8
                                               , flightnumber, flightbunk, flightdate, flightcity
                                               );
                        OleDbCommand cmd = new OleDbCommand(cmdString, GlobalVar.cn);
                        cmd.ExecuteNonQuery();
                        importsucc++;
                    }
                }
                catch (Exception ex)
                {
                    GlobalApi.appenderrormessage(ex.Message);
                }
            }
            FormMain.LABEL.Text = string.Format("导入ABMS报表完成,共{0}张,其中成功导入{1}张  ", dt.Rows.Count, importsucc);
            GlobalApi.appenderrormessage(FormMain.LABEL.Text + filename);
        }
Exemple #12
0
 public static void importOneLineFromTpr(string line, string filename)
 {
     try
     {
         if (line.Trim().Length < 63)
         {
             return;
         }
         if (line[0] > '9' || line[0] < '0')
         {
             return;
         }
         string str        = line.Trim().ToUpper();
         string tktnumber  = str.Substring(0, 14).Trim();
         string orig_dest  = str.Substring(18, 9).Trim();
         string collection = str.Substring(27, 10).Trim();
         string tax        = str.Substring(37, 10).Trim();
         string comm       = str.Substring(47, 11).Trim();//没导入
         string pnr        = str.Substring(58, 6).Trim();
         if (pnr.Length != 5)
         {
             pnr = str.Substring(58);
             string[] p = pnr.Split(' ');
             for (int i = 0; i < p.Length; i++)
             {
                 if (p[i].Trim().Length == 5)
                 {
                     pnr = p[i].Trim();
                     break;
                 }
             }
         }
         string dateofsale = GlobalApi.getDateOfSale(filename);
         //判断票号是否已经入库
         string number = tktnumber.Substring(4);
         {
             string           cmdString = string.Format("select * from etickets where TKTNUMBER='{0}'", number);
             OleDbCommand     cmd       = new OleDbCommand(cmdString, GlobalVar.cn);
             DataTable        dt        = new DataTable();
             OleDbDataAdapter adapter   = new OleDbDataAdapter(cmd);
             adapter.Fill(dt);
             if (dt.Rows.Count != 1)
             {
                 throw new Exception(number + "票号未入库");
             }
         }
         //更新数据库
         {
             FormMain.LABEL.Text = string.Format("正在导入tpr报表:票号{0}", tktnumber);
             Application.DoEvents();
             string cmdString = "update etickets set ";
             if (tktnumber.Length == 14)
             {
                 cmdString += string.Format("[E-TKT-NUMBER]='{0}'", tktnumber);
             }
             if (orig_dest.Contains("REFUND"))
             {
                 cmdString += string.Format(", [ORIG-DEST]='{0}',[TKT-FLAG]='4'", orig_dest);//cmdString += ", [TKT-FLAG]='4'";
             }
             else if (orig_dest.Contains("VOID"))
             {
                 cmdString += string.Format(", [ORIG-DEST]='{0}',[TKT-FLAG]='2'", orig_dest);//cmdString += ", [TKT-FLAG]='2'";
             }
             else if (orig_dest.Length == 7)
             {
                 cmdString += string.Format(", [ORIG-DEST]='{0}',[TKT-FLAG]='1'", orig_dest);//cmdString += ", [TKT-FLAG]='1'";
             }
             if (dateofsale != "")
             {
                 cmdString += string.Format(", DATEOFSALE='{0}'", dateofsale);
             }
             if (collection.Length != 0 && collection.IndexOf('.') > 0)
             {
                 cmdString += string.Format(", COLLECTION={0}", int.Parse(collection.Split('.')[0]));
             }
             if (tax.Length != 0 && tax.IndexOf('.') > 0)
             {
                 cmdString += string.Format(", TAXS={0}", int.Parse(tax.Split('.')[0]));
             }
             if (pnr.Length == 5)
             {
                 cmdString += string.Format(", PNR='{0}'", pnr);
             }
             cmdString += string.Format(", IMPORTCOUNT=IMPORTCOUNT+1");
             cmdString += string.Format(" where TKTNUMBER='{0}'", number);
             OleDbCommand cmd = new OleDbCommand(cmdString, GlobalVar.cn);
             cmd.ExecuteNonQuery();
             GlobalVar.countStat++;
         }
     }
     catch (Exception ex)
     {
         //MessageBox.Show(ex.Message);
         GlobalApi.appenderrormessage("importOneLineFromTpr: " + ex.Message);
     }
 }