Example #1
0
        private void btthem_Click(object sender, EventArgs e)
        {
            if (txttenncc.Text == "" || txtsdt.Text == "" || txtdiachi.Text == "" || IsNumber(txtsdt.Text) == false)
            {
                MessageBox.Show("Thông tin chưa đầy đủ hoặc sai định dạng, vui lòng kiểm tra lại!");
            }
            else
            {
                Nhacungcap_DTO nccDTO = new Nhacungcap_DTO();
                nccDTO.SMancc          = txtmancc.Text;
                nccDTO.STencc          = txttenncc.Text;
                nccDTO.SSodienthoaincc = txtsdt.Text;
                nccDTO.SDiachincc      = txtdiachi.Text;

                if (Nhacungcap_BUS.Themncc(nccDTO) == true)
                {
                    MessageBox.Show("Lưu thành công");
                    LoadDgvNhacungcap();
                }
                else
                {
                    MessageBox.Show("Thất bại!");
                }
            }
        }
        //load san pham
        public static List <Nhacungcap_DTO> LoadNhaCungCap()
        {
            string sTruyvan = "select * from NHACUNGCAP";

            con = DataProvider.Ketnoi();
            DataTable dt = DataProvider.LayDataTable(sTruyvan, con);

            if (dt.Rows.Count == 0)
            {
                return(null);
            }
            List <Nhacungcap_DTO> listncc = new List <Nhacungcap_DTO>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                Nhacungcap_DTO ncc = new Nhacungcap_DTO();
                ncc.SMancc          = dt.Rows[i]["MANCC"].ToString();
                ncc.STencc          = dt.Rows[i]["TENNCC"].ToString();
                ncc.SSodienthoaincc = dt.Rows[i]["SDT"].ToString();
                ncc.SDiachincc      = dt.Rows[i]["DIACHI"].ToString();

                listncc.Add(ncc);
            }
            return(listncc);
        }
Example #3
0
        private void btxoa_Click(object sender, EventArgs e)
        {
            Nhacungcap_DTO nccDTO = new Nhacungcap_DTO();

            nccDTO.SMancc = txtmancc.Text;
            if (Nhacungcap_BUS.Xoancc(nccDTO) == true)
            {
                MessageBox.Show("Đã xóa");
                LoadDgvNhacungcap();
            }
            else
            {
                MessageBox.Show("Thất bại!");
            }
        }
        public static String MaNCCTutang()
        {
            Nhacungcap_DTO TGBH = new Nhacungcap_DTO();

            con = DataProvider.Ketnoi();
            var cmd = new SqlCommand("NhaCungCap_TOP", con);

            cmd.CommandType = CommandType.StoredProcedure;
            var Adapter = new SqlDataAdapter(cmd);
            var table   = new DataTable();

            Adapter.Fill(table);
            string sMaNCC = table.Rows[0]["MANCC"].ToString();

            DataProvider.Dongketnoi(con);
            return(sMaNCC);
        }
Example #5
0
        //private void dgvncc_CellContentClick(object sender, DataGridViewCellEventArgs e)
        //{
        //    DataGridViewRow dr1 = dgvncc.SelectedRows[0];

        //    txtmancc.Text = dr1.Cells["SMancc"].Value.ToString();
        //    txttenncc.Text = dr1.Cells["STencc"].Value.ToString();
        //    txtsdt.Text = dr1.Cells["SSodienthoaincc"].Value.ToString();
        //    txtdiachi.Text = dr1.Cells["SDiachincc"].Value.ToString();

        //}

        private void dtsua_Click(object sender, EventArgs e)
        {
            Nhacungcap_DTO nccDTO = new Nhacungcap_DTO();

            nccDTO.SMancc          = txtmancc.Text;
            nccDTO.STencc          = txttenncc.Text;
            nccDTO.SSodienthoaincc = txtsdt.Text;
            nccDTO.SDiachincc      = txtdiachi.Text;

            if (Nhacungcap_BUS.Suancc(nccDTO) == true)
            {
                MessageBox.Show("Cập nhật thành công");
                LoadDgvNhacungcap();
            }
            else
            {
                MessageBox.Show("Thất bại!");
            }
        }
        public static bool XoaNCC(Nhacungcap_DTO XoaNCC)
        {
            string sTruyvan = string.Format(" DELETE FROM NHACUNGCAP WHERE  MANCC='{0}'", XoaNCC.SMancc);

            //string sTruyvan = "insert into khoa values('" + txtMASP+ "',N'" + txtTENSP.Text + "')";

            con = DataProvider.Ketnoi();
            try
            {
                DataProvider.ThucThiTruyVanNonQuerry(sTruyvan, con);
                DataProvider.Dongketnoi(con);
                return(true);
            }
            catch (Exception ex)
            {
                DataProvider.Dongketnoi(con);
                return(false);
            }
        }
        public static bool SuaNCC(Nhacungcap_DTO SuaNCC)
        {
            string sTruyvan = string.Format(" Update NHACUNGCAP set TENNCC=N'{0}',SDT=N'{1}',DIACHI=N'{2}' WHERE MANCC='{3}' ", SuaNCC.STencc, SuaNCC.SSodienthoaincc, SuaNCC.SDiachincc, SuaNCC.SMancc);

            //string sTruyvan = "insert into khoa values('" + txtMASP+ "',N'" + txtTENSP.Text + "')";

            con = DataProvider.Ketnoi();
            try
            {
                DataProvider.ThucThiTruyVanNonQuerry(sTruyvan, con);
                DataProvider.Dongketnoi(con);
                return(true);
            }
            catch (Exception ex)
            {
                DataProvider.Dongketnoi(con);
                return(false);
            }
        }
        public static bool ThemNCC(Nhacungcap_DTO ThemNCC)
        {
            string sTruyvan = string.Format(@"insert into NHACUNGCAP (MANCC,TENNCC,SDT, DIACHI) values ('{0}',N'{1}',N'{2}',N'{3}') ", ThemNCC.SMancc, ThemNCC.STencc, ThemNCC.SSodienthoaincc, ThemNCC.SDiachincc);

            //string sTruyvan = "insert into khoa values('" + txtMASP+ "',N'" + txtTENSP.Text + "')";

            con = DataProvider.Ketnoi();
            try
            {
                DataProvider.ThucThiTruyVanNonQuerry(sTruyvan, con);
                DataProvider.Dongketnoi(con);
                return(true);
            }
            catch (Exception ex)
            {
                DataProvider.Dongketnoi(con);
                return(false);
            }
        }
Example #9
0
 public static bool Xoancc(Nhacungcap_DTO XoaNCC)
 {
     return(Nhacungcap_DAO.XoaNCC(XoaNCC));
 }
Example #10
0
 public static bool Suancc(Nhacungcap_DTO SuaNCC)
 {
     return(Nhacungcap_DAO.SuaNCC(SuaNCC));
 }
Example #11
0
 public static bool Themncc(Nhacungcap_DTO ThemNCC)
 {
     return(Nhacungcap_DAO.ThemNCC(ThemNCC));
 }