Exemplo n.º 1
0
        public void addFukuandan(Fukuan p)
        {
            MySqlConnection conn = Util.Util.getConn();
            MySqlCommand    command;

            try
            {
                command             = conn.CreateCommand();
                command.CommandText = "INSERT INTO payfor_money(payfor_zhanghu,payfor_money,payfor_way,mark,payfor_suppliernumber,employee_number,date,payfor_danjuid) VALUES(@payfor_zhanghu,@payfor_money,@payfor_way,@mark,@payfor_suppliernumber,@employee_number,@date,@payfor_danjuid)";
                command.Parameters.AddWithValue("@payfor_zhanghu", p.Payfor_zhanghu);
                command.Parameters.AddWithValue("@payfor_money", p.Payfor_money);
                command.Parameters.AddWithValue("@payfor_way", p.Payfor_way);
                command.Parameters.AddWithValue("@mark", p.Mark);
                command.Parameters.AddWithValue("@payfor_suppliernumber", p.Payfor_suppliernumber);
                command.Parameters.AddWithValue("@employee_number", p.Employee_number);
                command.Parameters.AddWithValue("@date", p.Date);
                command.Parameters.AddWithValue("@payfor_danjuid", p.Payfor_danjuid);
                command.ExecuteNonQuery();
                //MessageBox.Show("插入成功");
            }
            catch (Exception)
            {
                MessageBox.Show("插入失败");
            }

            finally
            {
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
        }
Exemplo n.º 2
0
        public int selectPayfor_date1(DateTime date1, DateTime date2)
        {
            MySqlConnection conn            = Util.Util.getConn();
            MySqlDataReader dataReader      = null;
            MySqlCommand    command         = null;
            Fukuan          fu              = null;
            Int16           sumpayfor_money = 0;

            try
            {
                command             = conn.CreateCommand();
                command.CommandText = "SELECT sum(payfor_money) FROM payfor_money where date>='" + date1 + "'and date<='" + date2 + "'";
                dataReader          = command.ExecuteReader();
                Console.WriteLine(command.CommandText);
                while (dataReader.Read())
                {
                    sumpayfor_money = dataReader.GetInt16(0);
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                if (!dataReader.IsClosed)
                {
                    dataReader.Close();
                }
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(sumpayfor_money);
        }
Exemplo n.º 3
0
        //按照单据日期和客户查询
        public List <Fukuan> selectPayfor_dateandkehuname(DateTime date1, DateTime date2, string supplier_name)
        {
            MySqlConnection conn       = Util.Util.getConn();
            MySqlDataReader dataReader = null;
            MySqlCommand    command    = null;
            Fukuan          fu         = null;
            List <Fukuan>   rs         = new List <model.Fukuan>();

            try
            {
                command             = conn.CreateCommand();
                command.CommandText = "SELECT * FROM payfor_money where date>='" + date1 + "'and date<='" + date2 + "'and payfor_suppliernumber='" + supplier_name + "'";
                dataReader          = command.ExecuteReader();
                Console.WriteLine();
                while (dataReader.Read())
                {
                    fu                       = new Fukuan();
                    fu.Id                    = dataReader.GetInt16(0);
                    fu.Payfor_zhanghu        = dataReader.GetString(1);
                    fu.Payfor_money          = dataReader.GetString(2);
                    fu.Payfor_way            = dataReader.GetString(3);
                    fu.Mark                  = dataReader.GetString(4);
                    fu.Payfor_suppliernumber = dataReader.GetString(5);
                    fu.Employee_number       = dataReader.GetString(6);
                    fu.Date                  = dataReader.GetDateTime(7);
                    fu.Payfor_danjuid        = dataReader.GetString(8);
                    rs.Add(fu);
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                if (!dataReader.IsClosed)
                {
                    dataReader.Close();
                }
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(rs);
        }
Exemplo n.º 4
0
        private void button4_Click(object sender, EventArgs e)
        {
            bool b = true;

            if (dataGridView1.Rows.Count == 1)
            {
                MessageBox.Show("请填写信息");
                b = false;
            }
            else
            {
                for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                {
                    if (dataGridView1.Rows[i].Cells[0].Value == null)
                    {
                        MessageBox.Show("结算账户不能为空");
                        b = false;
                    }
                    else if (dataGridView1.Rows[i].Cells[1].Value == null)
                    {
                        MessageBox.Show("付款金额不能为空");
                        b = false;
                    }
                    else if (dataGridView1.Rows[i].Cells[2].Value == null)
                    {
                        MessageBox.Show("结算方式不能为空");
                        b = false;
                    }
                    else if (textBox1.Text == null)
                    {
                        MessageBox.Show("供应商不能为空");
                        b = false;
                    }
                    else if (textBox2.Text == null)
                    {
                        MessageBox.Show("操作人不能为空");
                        b = false;
                    }
                }
            }
            if (b == false)
            {
            }
            else
            {
                MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
                DialogResult      dr         = MessageBox.Show("是否确认保存?", "提交", messButton);
                if (dr == DialogResult.OK)
                {
                    string[] supplier1 = textBox1.Text.Split(' ');
                    string[] employer  = textBox2.Text.Split(' ');
                    try
                    {
                        ZijinDao dao = new ZijinDao();
                        for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                        {
                            Fukuan p = new Fukuan();
                            Console.Write(dataGridView1.Rows[i].Cells[0].Value + "lallalalaalalalalalalla");
                            p.Payfor_zhanghu = dataGridView1.Rows[i].Cells[0].Value.ToString();
                            p.Payfor_money   = dataGridView1.Rows[i].Cells[1].Value.ToString();
                            p.Payfor_way     = dataGridView1.Rows[i].Cells[2].Value.ToString();
                            if (dataGridView1.Rows[i].Cells[3].Value == null)
                            {
                                p.Mark = "";
                            }
                            else
                            {
                                p.Mark = dataGridView1.Rows[i].Cells[3].Value.ToString();
                            }
                            p.Payfor_suppliernumber = supplier1[0];
                            p.Employee_number       = employer[0];
                            p.Date           = Convert.ToDateTime(dateTimePicker1.Text);
                            p.Payfor_danjuid = textBox3.Text;
                            dao.addFukuandan(p);
                        }
                        MessageBox.Show("保存成功");
                        dataGridView1.Rows.Clear();
                    }
                    catch (SystemException)
                    {
                        MessageBox.Show("操作有误");
                    }
                }
                else
                {
                }
            }
        }