Ejemplo n.º 1
0
 private void Init()
 {
     cbInout.SelectedIndex     = 0;
     cbOpenInOut.SelectedIndex = 0;
     dgvDataList          = new DataInputManager().InitBoxInfoDataGridView(dgvDataList);
     dgvDataList.EditMode = DataGridViewEditMode.EditProgrammatically;
 }
Ejemplo n.º 2
0
 //保存
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(lblID.Text))
     {
         //这里是选择的记录   可以更改以前的内容
         //保存标题内容
         BillIndex biUpdate = new BaseService <BillIndex>().GetRecord(" id=" + lblID.Text);  //读取索引记录
         biUpdate.Voyage = txtVoyage.Text;
         biUpdate.ShipNo = txtCH.Text;
         if (new BaseService <BillIndex>().UpdateRecord(biUpdate) == 0)
         {
             lberror.Text = "在保存航线的时候出现异常";
             return;
         }
         //保存详细箱内容
         lberror.Text = new DataInputManager().UpdateBill(bills, lblID.Text);
         if (lberror.Text == "")
         {
             MessageBox.Show("保存成功,请不要重复操作!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         //这里是导入的记录
         //判断是否存在记录 sql = "select Count(*) from BillIndex where title='" + bi.Title + "' and date(reg_date,'localtime') = date('" + bi.Reg_Date.ToString("yyyy-MM-dd") + "','localtime')";
         BillIndex bi = new DataInputManager().GetBillIndex(" title='" + txtOpenTitle.Text + "' and date(reg_date,'localtime') = date('" + DateTime.Parse(txtOpenDate.Text).ToString("yyyy-MM-dd") + "','localtime')");
         if (!string.IsNullOrEmpty(bi.ID))
         {
             MessageBox.Show("数据库中已经存在相同的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             try
             {
                 //加入数据库
                 bi = new BillIndex()
                 {
                     InOut = cbOpenInOut.Text, Title = txtOpenTitle.Text, Reg_Date = DateTime.Parse(txtOpenDate.Text), Voyage = txtVoyage.Text
                 };
                 lberror.Text = new DataInputManager().InsertBill(bills, bi);
                 if (lberror.Text == "")
                 {
                     MessageBox.Show("成功保存到数据库!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
             catch (Exception ex)
             {
                 lberror.Text = ex.Message;
             }
         }
     }
 }
Ejemplo n.º 3
0
        private Dictionary <string, int> stru;    //结构
        private void txtOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect = false;
            ofd.Filter      = "Excel2003文件|*.xls";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                txtOpenTitle.Text = "";
                txtOpenDate.Text  = "";
                txtOpen.Text      = ofd.FileName;
                //自动提取表格头部信息
                string    error = "";
                BillIndex bi    = new ExcelHelper().GetExcelBillTopInfomation(txtOpen.Text, ref error);
                if (error != "EDI数据" && error != "手动数据" && error != "")
                {
                    lberror.Text = error;
                    return;
                }

                if (error == "手动数据" && bi.Title != "")    //能正确读出结果
                {
                    txtOpenTitle.Text = bi.Title;
                    txtOpenDate.Text  = bi.Reg_Date.ToShortDateString();
                    txtVoyage.Text    = bi.Voyage;
                    if (!string.IsNullOrEmpty(bi.InOut))
                    {
                        cbOpenInOut.Text = bi.InOut;
                    }
                    else
                    {
                        if (txtOpenTitle.Text.IndexOf("卸船") >= 0)
                        {
                            cbOpenInOut.Text = "进口";
                        }
                        if (txtOpenTitle.Text.IndexOf("装船") >= 0)
                        {
                            cbOpenInOut.Text = "出口";
                        }
                    }
                    //查询船舶名称
                    string   shipname = bi.Title.IndexOf('/') > 0 ? bi.Title.Substring(0, bi.Title.IndexOf('/')) : bi.Title;
                    ShipInfo si       = new DataInputManager().GetShipInfo(shipname);
                    if (string.IsNullOrEmpty(si.ID))
                    {
                        MessageBox.Show("请注意,本Excel数据无法确定船舶[" + shipname + "]属性。", "注意", MessageBoxButtons.OK, MessageBoxIcon.Question);
                    }
                    stru = bi.Stru;

                    btnLoad.Enabled = true;
                }

                if (error == "EDI数据" && bi.Title != "")
                {
                    txtOpenTitle.Text = bi.Title;



                    btnLoad.Enabled = false;
                }
            }
        }