예제 #1
0
        //MENU CHI NHANH
        public bool themMenuChiNhanh(MenuChiNhanh menu)
        {
            var cm = CreateCommand();

            cm.CommandText = @"insert into MenuChiNhanh (maCN,maMA,ghiChu) values (@a,@b,@c)";
            cm.Parameters.Add(new SqlParameter("@a", menu.MaCN));
            cm.Parameters.Add(new SqlParameter("@b", menu.MaMA));
            cm.Parameters.Add(new SqlParameter("@c", menu.GhiChu));
            int rs = cm.ExecuteNonQuery();

            cn.Close();
            return(rs > 0);
        }
예제 #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            var cn = new ChiNhanh();

            cn.DienThoai = textBox5.Text;
            cn.TinhThanh = textBox3.Text;
            cn.DiaChi    = textBox7.Text;
            cn.TenCN     = textBox8.Text;
            var  sql  = new GetDataFromSQL();
            bool temp = sql.themChiNhanh(cn);

            cn.MaCN = sql.timMaChiNhanh(cn.TenCN);
            bool test = false;

            foreach (DataGridViewRow row in dataGridView2.Rows)
            {
                var menu = new MenuChiNhanh();
                menu.MaMA   = sql.timMaMonAn(Convert.ToString(row.Cells["ten"].Value));
                menu.GhiChu = Convert.ToString(row.Cells["ghichu"].Value);
                menu.MaCN   = cn.MaCN;
                if (sql.themMenuChiNhanh(menu))
                {
                    test = true;
                }
                else
                {
                    return;
                }
            }
            if (temp == true && test == true)
            {
                MessageBox.Show("Thêm chi nhánh thành công!");
            }
            else
            {
                MessageBox.Show("Không thêm được chi nhánh!");
            }
            this.Close();
        }