Example #1
0
 private void dataGridView1_MouseClick(object sender, MouseEventArgs e)
 {
     if (GetRowIndexAt(e.Y) == -1)
     {
         CleanTextBox();
         newinfo = GetNewInfo();
         this.btnNextOrModify.Text = "下一个";
         this.groupBox1.Text       = "数据添加";
         if (this.dataGridView1.Rows.Count <= 0)
         {
             this.dt1.Text = DateTime.Now.ToShortDateString();
         }
         else
         {
             DateTime dt = Convert.ToDateTime(bll.getZongJie().list[bll.getZongJie().list.Count - 1].dtime);
             this.dt1.Text = dt.Date.AddDays(1).ToString();
         }
         modify_flag = false;
         return;
     }
     this.dt1.Text             = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
     this.txtSummary.Text      = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
     this.txtFlightM.Text      = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
     this.txtTrainM.Text       = "0.0";
     this.txtTaxiM.Text        = dataGridView1.SelectedRows[0].Cells[3].Value.ToString();
     this.txtOtherM.Text       = dataGridView1.SelectedRows[0].Cells[4].Value.ToString();
     this.txtZhusuM.Text       = dataGridView1.SelectedRows[0].Cells[5].Value.ToString();
     this.txtAllowanceM.Text   = dataGridView1.SelectedRows[0].Cells[6].Value.ToString();
     this.txtTotalM.Text       = dataGridView1.SelectedRows[0].Cells[7].Value.ToString();
     this.btnNextOrModify.Text = "修改";
     this.groupBox1.Text       = "数据修改";
     newinfo     = GetNewInfo();
     modify_flag = true;
 }
Example #2
0
 //加入到datagridview中
 private void addToGridView(travelInfo newinfo)
 {
     try
     {
         DataGridViewRow drow = new DataGridViewRow();
         //int index = dataGridView1.Rows.Add(drow);
         //dataGridView1.Rows[index].Cells[0].Value= newinfo.dtime;
         //dataGridView1.Rows[index].Cells[1].Value = newinfo.summary;
         //dataGridView1.Rows[index].Cells[2].Value = (newinfo.flyticket + newinfo.trainticket).ToString();
         //dataGridView1.Rows[index].Cells[3].Value = newinfo.taxiticket.ToString();
         //dataGridView1.Rows[index].Cells[4].Value = newinfo.otherpay.ToString();
         //dataGridView1.Rows[index].Cells[5].Value = newinfo.accomadationpay.ToString();
         //dataGridView1.Rows[index].Cells[6].Value = newinfo.allowance.ToString();
         //dataGridView1.Rows[index].Cells[7].Value = newinfo.totalpay.ToString();
         DataGridViewTextBoxCell[] textcell = new DataGridViewTextBoxCell[8];
         for (int i = 0; i < 8; i++)
         {
             textcell[i] = new DataGridViewTextBoxCell();
         }
         textcell[1].Value = newinfo.summary;
         textcell[0].Value = newinfo.dtime;
         textcell[2].Value = (newinfo.flyticket + newinfo.trainticket).ToString();
         textcell[3].Value = newinfo.taxiticket.ToString();
         textcell[4].Value = newinfo.otherpay.ToString();
         textcell[5].Value = newinfo.accomadationpay.ToString();
         textcell[6].Value = newinfo.allowance.ToString();
         textcell[7].Value = newinfo.totalpay.ToString();
         drow.Cells.AddRange(textcell);
         dataGridView1.Rows.Add(drow);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #3
0
        private void BaoXiaoFrm_Load(object sender, EventArgs e)
        {
            listViewNF1.LargeImageList           = largeimagelist = new ImageList();
            listViewNF1.SmallImageList           = smallimagelist = new ImageList();
            listViewNF1.LargeImageList.ImageSize = new Size(32, 32);
            listViewNF1.SmallImageList.ImageSize = new Size(16, 16);
            listViewNF1.View = View.Tile;
            string dt       = DateTime.Now.Year.ToString();
            string destpath = Path.Combine(System.Configuration.ConfigurationManager.AppSettings["baoxiao_path"], dt);

            if (Directory.Exists(destpath))
            {
                //load file
                CommonHelper.loadFile(destpath, this.listViewNF1, this.largeimagelist, this.smallimagelist);
                //load data from textbox;
                //开始时将newinfo初始化,都是0,点击修改的时候newinfo应该是获取这个datagridview选中行的值,当下面选项卡textbox发生任何变化时都会改变这个newinfo的值,当不选中datagridview行时,这个newinfo值为0,为输入新数据做准备。
                newinfo                  = GetNewInfo();
                basic_allowance          = float.Parse(this.txtAllowanceM.Text.Trim());
                btnFinish.Enabled        = true;
                btnGenerateExcel.Enabled = true;
                btnNextOrModify.Enabled  = true;
            }
            else
            {
                MessageBox.Show("没有报销文件需要修改或者添加,请添加新的报销文件后再修改!");
            }
        }
Example #4
0
        public bool ModifyData(travelInfo info, int index)
        {
            try
            {
                travelInfo olddata = zongjie.list[index];

                //计算总额
                zongjie.totalfly     += (info.flyticket - olddata.flyticket);
                zongjie.totaltrain   += (info.trainticket - olddata.trainticket);
                zongjie.totaltaxi    += (info.taxiticket - olddata.taxiticket);
                zongjie.totalqita    += (info.otherpay - olddata.otherpay);
                zongjie.totalzhusu   += (info.accomadationpay - olddata.accomadationpay);
                zongjie.totalbutie   += (info.allowance - olddata.allowance);
                zongjie.totalzongshu += (info.totalpay - olddata.totalpay);
                if (info.Ppayfly)
                {//私人付款
                    zongjie.baoxiaojine += (info.totalpay - olddata.totalpay - olddata.flyticket);
                }
                else
                {//公司付款
                    zongjie.baoxiaojine += (info.totalpay - olddata.totalpay - olddata.flyticket - info.flyticket);
                }

                //替换原来的class值
                zongjie.list[index] = info;
                return(true);
            }
            catch (Exception ex)
            {
                LogHelper.log(ex.Message);
                return(false);
            }
        }
Example #5
0
 private void modifyDatagridView(travelInfo newinfo)
 {
     dataGridView1.CurrentRow.Cells[0].Value = newinfo.dtime;
     dataGridView1.CurrentRow.Cells[1].Value = newinfo.summary;
     dataGridView1.CurrentRow.Cells[2].Value = (newinfo.flyticket + newinfo.trainticket).ToString();
     dataGridView1.CurrentRow.Cells[3].Value = newinfo.taxiticket.ToString();
     dataGridView1.CurrentRow.Cells[4].Value = newinfo.otherpay.ToString();
     dataGridView1.CurrentRow.Cells[5].Value = newinfo.accomadationpay.ToString();
     dataGridView1.CurrentRow.Cells[6].Value = newinfo.allowance.ToString();
     dataGridView1.CurrentRow.Cells[7].Value = newinfo.totalpay.ToString();
 }
Example #6
0
        //下面是连接到数据库
        public List <travelInfo> GetMemberList(string tableName)
        {
            string            sql  = "select * from " + tableName;
            DataTable         da   = SQLiteHelper.ExecteDataTable(sql);
            List <travelInfo> list = null;

            if (da.Rows.Count > 0)
            {
                list = new List <travelInfo>();
                travelInfo memberinfo = null;
                foreach (DataRow row in da.Rows)
                {
                    memberinfo = new travelInfo();
                    LoadEntity(memberinfo, row);
                    list.Add(memberinfo);
                }
            }
            zongjie.list = list;
            return(list);
        }
Example #7
0
 /// <summary>
 /// 用来记录新添加的数值变化前的数值,为中间变量
 /// </summary>
 private travelInfo GetNewInfo()
 {
     try
     {
         travelInfo newinfo = new travelInfo();
         newinfo.dtime           = this.dt1.Text;
         newinfo.summary         = this.txtSummary.Text.Trim();
         newinfo.flyticket       = float.Parse(this.txtFlightM.Text.Trim());
         newinfo.Ppayfly         = this.checkBox1.Checked;
         newinfo.trainticket     = float.Parse(this.txtTrainM.Text.Trim());
         newinfo.taxiticket      = float.Parse(this.txtTaxiM.Text.Trim());
         newinfo.otherpay        = float.Parse(this.txtOtherM.Text.Trim());
         newinfo.accomadationpay = float.Parse(this.txtZhusuM.Text.Trim());
         newinfo.allowance       = float.Parse(this.txtAllowanceM.Text.Trim());
         newinfo.totalpay        = float.Parse(this.txtTotalM.Text.Trim());
         return(newinfo);
     }
     catch
     {
         return(null);;
     }
 }
Example #8
0
 private travelInfo LoadEntry()
 {
     try
     {
         travelInfo info = new travelInfo();
         info.dtime       = this.dt1.Text;
         info.summary     = this.txtSummary.Text;
         info.flyticket   = Convert.ToSingle(this.txtSummary.Text);
         info.trainticket = float.Parse(this.txtTrainM.Text);
         info.taxiticket  = Convert.ToSingle(this.txtTaxiM.Text);
         float otherM = Convert.ToSingle(this.txtOtherM.Text);
         info.otherpay        = info.trainticket > 0 ? (otherM + 100) : otherM;
         info.accomadationpay = Convert.ToSingle(this.txtZhusuM.Text);
         info.allowance       = Convert.ToSingle(this.txtAllowanceM.Text);
         info.totalpay        = Convert.ToSingle(this.txtTotalM.Text);
         return(info);
     }
     catch
     {
         return(default(travelInfo));
     }
 }
Example #9
0
 public void excel2ZongJie(string strFileName)
 {
     try
     {
         Workbook  book  = new Workbook(strFileName);
         Worksheet sheet = book.Worksheets[0];
         Cells     cells = sheet.Cells;
         int       rows  = cells.MaxDataRow + 1;
         #region 零散数据添加
         zongjie.title        = cells["A1"].StringValue;
         zongjie.baoxiaojine  = Convert.ToSingle(cells[rows - 2, 2].Value);
         zongjie.jiekuan      = Convert.ToSingle(cells[rows - 3, 2].Value);
         zongjie.totalfly     = Convert.ToSingle(cells[rows - 4, 2].Value);
         zongjie.totaltaxi    = Convert.ToSingle(cells[rows - 5, 3].Value);
         zongjie.totalqita    = Convert.ToSingle(cells[rows - 5, 4].Value);
         zongjie.totalzhusu   = Convert.ToSingle(cells[rows - 5, 5].Value);
         zongjie.totalbutie   = Convert.ToSingle(cells[rows - 5, 6].Value);
         zongjie.totalzongshu = Convert.ToSingle(cells[rows - 5, 7].Value);
         #endregion
         travelInfo info;
         for (int i = 3; i < rows - 5; i++)
         {
             info                 = new travelInfo();
             info.dtime           = cells[i, 0].StringValue;
             info.summary         = cells[i, 1].StringValue;
             info.flyticket       = Convert.ToSingle(cells[i, 2].Value);
             info.taxiticket      = Convert.ToSingle(cells[i, 3].Value);
             info.otherpay        = Convert.ToSingle(cells[i, 4].Value);
             info.accomadationpay = Convert.ToSingle(cells[i, 5].Value);
             info.allowance       = Convert.ToSingle(cells[i, 6].Value);
             info.totalpay        = Convert.ToSingle(cells[i, 7].Value);
             zongjie.list.Add(info);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Example #10
0
        public bool AddNew(travelInfo info)
        {
            try
            {
                zongjie.list.Add(info);
                //计算添加的行数
                int len = zongjie.list.Count;
                zongjie.addrowcount++;
                //计算总额

                zongjie.totalfly     += (info.flyticket);
                zongjie.totaltrain   += info.trainticket;
                zongjie.totaltaxi    += info.taxiticket;
                zongjie.totalqita    += info.otherpay;
                zongjie.totalzhusu   += info.accomadationpay;
                zongjie.totalbutie   += info.allowance;
                zongjie.totalzongshu += info.totalpay;
                //私人付款
                if (info.Ppayfly)
                {
                    zongjie.baoxiaojine += info.totalpay;
                }
                else
                {
                    //公司付款,报销金额-机票钱
                    zongjie.baoxiaojine += (info.totalpay - info.flyticket);
                }

                return(true);
            }
            catch (Exception ex)
            {
                LogHelper.log(ex.Message);
                return(false);
            }
        }
Example #11
0
 public bool ModifyData(travelInfo info, int index)
 {
     return(dal.ModifyData(info, index));
 }
Example #12
0
 public bool AddNew(travelInfo info)
 {
     return(dal.AddNew(info));
 }
Example #13
0
        //下一步
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.listviewitem_selected == false)
            {
                MessageBox.Show("请先选择所要编辑的文件");
                return;
            }
            if (modify_flag == false)
            {
                if (this.txtSummary.Text == "")
                {
                    return;
                }
                newinfo = GetNewInfo();
                bll.AddNew(newinfo);
                SetTotalText(bll.getZongJie());
                //newinfo to datagridview
                addToGridView(newinfo);
                bll.addBorrowM(this.txtBorrowM.Text.Trim());
                btnFinish.Enabled = true;
                CleanTextBox();
                this.dt1.Text = this.dt1.Value.AddDays(1).ToString();
                //save newinfo to bll

                //last step
                newinfo = GetNewInfo();
            }
            else
            {
                //modify
                //修改,先将标志改为false,然后获取要更改的位置,替换zongjie中list的值,再检查借款是否需要修改,清空textbox,将最大日期+1天

                modify_flag = false;
                int index = this.dataGridView1.CurrentRow.Index;
                if (index < 0)
                {
                    return;
                }
                newinfo = GetNewInfo();
                bll.ModifyData(newinfo, index);
                this.btnNextOrModify.Text = "下一步";
                if (float.Parse(this.txtBorrowM.Text.Trim()) != 0)
                {
                    bll.addBorrowM(this.txtBorrowM.Text.Trim());
                }
                CleanTextBox();
                dt1.Text = dt1.Value.AddDays(1).ToString();
                if (dt1.Value < Convert.ToDateTime(this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[0].Value))
                {
                    int mindex = dataGridView1.SelectedRows[0].Index;
                    dataGridView1.Rows[mindex].Selected     = false;
                    dataGridView1.Rows[mindex + 1].Selected = true;
                    //
                    this.dt1.Text             = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
                    this.txtSummary.Text      = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
                    this.txtFlightM.Text      = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
                    this.txtTrainM.Text       = "0.0";
                    this.txtTaxiM.Text        = dataGridView1.SelectedRows[0].Cells[3].Value.ToString();
                    this.txtOtherM.Text       = dataGridView1.SelectedRows[0].Cells[4].Value.ToString();
                    this.txtZhusuM.Text       = dataGridView1.SelectedRows[0].Cells[5].Value.ToString();
                    this.txtAllowanceM.Text   = dataGridView1.SelectedRows[0].Cells[6].Value.ToString();
                    this.txtTotalM.Text       = dataGridView1.SelectedRows[0].Cells[7].Value.ToString();
                    this.btnNextOrModify.Text = "修改";
                    this.groupBox1.Text       = "数据修改";
                    modify_flag = true;
                }
                modifyDatagridView(newinfo);
                SetTotalText(bll.getZongJie());
            }
        }
Example #14
0
 private void LoadEntity(travelInfo memberinfo, DataRow row)
 {
     throw new NotImplementedException();
 }