protected void gvNCC_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            nhacungcap ncc  = new nhacungcap();
            int        MNCC = int.Parse(gvNCC.Rows[e.RowIndex].Cells[0].Text);

            ado.xoa_NhaCungCap(MNCC);
            Response.Write("<script>alert('Xóa thành công!');</script>");
            loadNCC();
        }
示例#2
0
        public ActionResult Suanhacungcap(int id)
        {
            nhacungcap thuonghieu = db.nhacungcaps.SingleOrDefault(n => n.MaNCC == id);

            if (thuonghieu == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(thuonghieu));
        }
        protected void gvNCC_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            int        MNCC  = int.Parse(gvNCC.DataKeys[e.NewSelectedIndex].Value.ToString());
            nhacungcap nhacc = new nhacungcap();

            nhacc             = ado.laynhacungcap(MNCC);
            txtMNCC.Text      = nhacc.MNCC1.ToString();
            TenNCC.Text       = nhacc.TenNCC1.ToString();
            txtDiaChiNCC.Text = nhacc.DiaChiNCC1.ToString();
            txtSDTNCC.Text    = nhacc.SDTNCC1.ToString();
        }
示例#4
0
        public ActionResult Xoanhacungcap(int id)
        {
            nhacungcap nhacungcap = db.nhacungcaps.SingleOrDefault(n => n.MaNCC == id);

            ViewBag.MaNCC = nhacungcap.MaNCC;
            if (nhacungcap == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(nhacungcap));
        }
        // xem nhà cung cấp
        public List <nhacungcap> XemNhaCC()
        {
            List <nhacungcap> list  = new List <nhacungcap>();
            string            query = "select ma, ten, diachi,sodienthoai, email from nhacungcap";
            DataTable         data  = DataProvider.Instance.ExecuteQuery(query);

            foreach (DataRow item in data.Rows)
            {
                nhacungcap ncc = new nhacungcap(item);
                list.Add(ncc);
            }
            return(list);
        }
        // tìm kiếm nhà cung cấp
        public List <nhacungcap> SearchNhaCC(string ma, string ten)
        {
            List <nhacungcap> list  = new List <nhacungcap>();
            string            query = string.Format("select * from nhacungcap mh where mh.ma like N'%{0}%' and mh.ten like N'%{1}%' ", ma, ten);
            DataTable         data  = DataProvider.Instance.ExecuteQuery(query);

            foreach (DataRow i in data.Rows)
            {
                nhacungcap mh = new nhacungcap(i);
                list.Add(mh);
            }
            return(list);
        }
示例#7
0
        public ActionResult Xacnhanxoanhacungcap(int id)
        {
            nhacungcap nhacungcap = db.nhacungcaps.SingleOrDefault(n => n.MaNCC == id);

            ViewBag.MaTH = nhacungcap.MaNCC;
            if (nhacungcap == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            db.nhacungcaps.DeleteOnSubmit(nhacungcap);
            db.SubmitChanges();
            return(RedirectToAction("Nhacungcap"));
        }
示例#8
0
        public ActionResult Suanhacungcap(nhacungcap thuonghieu, HttpPostedFileBase anhSanPham)
        {
            //var filename = Path.GetFileName(fileupload.FileName);
            //var path = Path.Combine(Server.MapPath("~/images/"), filename);

            //db.SubmitChanges();
            //db.THUONGHIEUs.InsertOnSubmit(thuonghieu);

            nhacungcap Thuonghieu = db.nhacungcaps.Single(p => p.MaNCC == thuonghieu.MaNCC);

            Thuonghieu.TenNCC    = thuonghieu.TenNCC;
            Thuonghieu.Diachi    = thuonghieu.Diachi;
            Thuonghieu.DienThoai = thuonghieu.DienThoai;
            db.SubmitChanges();
            return(RedirectToAction("Nhacungcap"));
        }
 protected void btnthem_Click(object sender, EventArgs e)
 {
     if (TenNCC.Text == "" || txtSDTNCC.Text == "" || txtDiaChiNCC.Text == "")
     {
         Response.Write("<script>alert('Chưa nhập đủ thông tin!');</script>");
     }
     else
     {
         nhacungcap ncc = new nhacungcap();
         //ncc.MNCC1 = int.Parse(txtMNCC.Text);
         ncc.TenNCC1    = TenNCC.Text.ToString();
         ncc.DiaChiNCC1 = txtDiaChiNCC.Text.ToString();
         ncc.SDTNCC1    = txtSDTNCC.Text.ToString();
         ado.them_NhaCungCap(ncc);
         loadNCC();
         Response.Write("<script>alert('Thêm nhà cung cấp thành công!');</script>");
     }
 }
示例#10
0
        public nhacungcap laynhacungcap(int MNCC)
        {
            string qry = "select * from NhaCungCap where MNCC=" + MNCC;

            using (SqlConnection connect = new SqlConnection(connectionString))
            {
                connect.Open();
                SqlCommand    cmd    = new SqlCommand(qry, connect);
                SqlDataReader reader = cmd.ExecuteReader();
                reader.Read();
                nhacungcap a = new nhacungcap();
                a.MNCC1      = reader.GetInt32(0);
                a.TenNCC1    = reader.GetString(1);
                a.DiaChiNCC1 = reader.GetString(2);
                a.SDTNCC1    = reader.GetString(3);
                cmd.Dispose();
                reader.Dispose();
                connect.Close();
                return(a);
            }
        }
示例#11
0
        private List <nhacungcap> GetData()
        {
            List <nhacungcap> lst = new List <nhacungcap>();
            string            loi = "";

            for (int i = 1; i < c1FlexGrid1.Rows.Count; i++)
            {
                if (c1FlexGrid1[i, "TT"].ToString().Equals("0") == false)
                {
                    try
                    {
                        loi = "";
                        nhacungcap _obj = new nhacungcap();
                        if (c1FlexGrid1[i, "ten"].ToString().Trim().Equals("") == true || c1FlexGrid1[i, "ten"] == null)
                        {
                            loi = "Tên nhà cung cấp không được để trắng.";
                            c1FlexGrid1.SetUserData(i, "ten", loi);
                            c1FlexGrid1.Rows[i].Style = cserror;
                        }
                        _obj.diachi    = c1FlexGrid1[i, "diachi"].ToString();
                        _obj.dienthoai = c1FlexGrid1[i, "dienthoai"].ToString();
                        _obj.ghichu    = c1FlexGrid1[i, "ghichu"].ToString();
                        if (c1FlexGrid1[i, "TT"].ToString().Equals("1") == true)
                        {
                            _obj.id = Guid.NewGuid().ToString(); c1FlexGrid1[i, "id"] = _obj.id.Trim();
                        }
                        if (c1FlexGrid1[i, "TT"].ToString().Equals("2") == true)
                        {
                            _obj.id = c1FlexGrid1[i, "id"].ToString();
                        }
                        _obj.ten   = c1FlexGrid1[i, "ten"].ToString();
                        _obj.daxoa = 0;
                        lst.Add(_obj);
                    }
                    catch { }
                }
            }
            return(lst);
        }
        private void HienThiTTPhieuNhap()
        {
            tblphieunhapkho   objpn = new tblphieunhapkho();
            tblphieunhapkhoBL ctrpn = new tblphieunhapkhoBL();

            objpn = ctrpn.GetByID(sidpn);
            try{
                nhacungcap   objnhacc = new nhacungcap();
                nhacungcapBL ctrnhacc = new nhacungcapBL();
                objnhacc         = ctrnhacc.GetByID(objpn.id_nguoicap.Trim());
                lbDiaChi.Text    = objnhacc.diachi;
                lbDienThoai.Text = objnhacc.dienthoai;
                lbNgayXuat.Text  = objpn.ngaytao.ToString("dd/MM/yyyy HH:mm:ss");
                lbTenKH.Text     = objnhacc.ten;
            }
            catch {
                lbDiaChi.Text    = "-/-";
                lbDienThoai.Text = "-/-";
                lbNgayXuat.Text  = "-/-";
                lbTenKH.Text     = "-/-";
            }
        }
示例#13
0
 private void cbNhaCC_SelectedIndexChanged(object sender, EventArgs e)
 {
     tblphieunhapkhoBL ctrpn = new tblphieunhapkhoBL();
     string sidnhacc = "";
     try { sidnhacc = cbNhaCC.SelectedValue.ToString().Trim(); }
     catch { }
     nhacungcap obj = new nhacungcap();
     nhacungcapBL ctr = new nhacungcapBL();
     obj = ctr.GetByID(sidnhacc);
     try
     {
         try
         {
             txtNoToaTruoc.Text = ctrpn.GetTienConNo(sidnhacc, dpkNgayNhap.Value).ToString("N0", CultureInfo.InvariantCulture);
         }
         catch { txtNoToaTruoc.Text = "0"; }
         txtDiaChi.Text = obj.diachi;
         txtDienThoai.Text = obj.dienthoai.Trim();
         double tongtien = 0;
         try { tongtien = Convert.ToDouble(txtTongTien.Text); }
         catch { }
         double tienconno = 0;
         try { tienconno = Convert.ToDouble(txtNoToaTruoc.Text); }
         catch { }
         double tientt = 0;
         try { tientt = Convert.ToDouble(txtTienThanhToan.Text); }
         catch { }
         double chietkhau = 0;
         try { chietkhau = Convert.ToDouble(txtChietKhau.Text); }
         catch { }
         txtConNo.Text = ((tienconno + tongtien) - (tientt + chietkhau)).ToString("N0", CultureInfo.InvariantCulture);
     }
     catch
     {
         txtDiaChi.Text = "";
         txtDienThoai.Text = "";
         txtTongTien.Text = "0";
     }
 }
示例#14
0
 public static bool CreateNhaCC(nhacungcap cc)
 {
     try
     {
         using (SieuThiDBDataContext db = new SieuThiDBDataContext())
         {
             var cc1 = new nhacungcap();
             cc1.tennhacungcap = cc.tennhacungcap;
             cc1.ma            = cc.ma;
             cc1.diachi        = cc.diachi;
             cc1.sodienthoai   = cc.sodienthoai;
             cc1.masothue      = cc.masothue;
             cc1.fax           = cc.fax;
             db.nhacungcaps.InsertOnSubmit(cc1);
             db.SubmitChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
示例#15
0
        public static bool UpdateNhaCC(nhacungcap _cc)
        {
            try
            {
                using (var db = new SieuThiDBDataContext())
                {
                    var cc = db.nhacungcaps.Single(x => x.ma == _cc.ma);
                    cc.tennhacungcap = _cc.tennhacungcap;
                    cc.ma            = _cc.ma;
                    cc.diachi        = _cc.diachi;
                    cc.sodienthoai   = _cc.sodienthoai;
                    cc.masothue      = _cc.masothue;
                    cc.fax           = _cc.fax;

                    db.SubmitChanges();
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
示例#16
0
        private void button3_Click(object sender, EventArgs e)
        {
            NHACUNGCAPDAL cmd  = new NHACUNGCAPDAL();
            nhacungcap    data = new nhacungcap();

            data.mancc     = txtma.Text;
            data.tenncc    = txtten.Text;
            data.diachi    = txtdiachi.Text;
            data.dienthoai = txtsdt.Text;


            bool kt = cmd.nhacungcap_delete(data);

            if (kt == false)
            {
                MessageBox.Show("Loi");
            }
            else
            {
                MessageBox.Show("Xóa thành công");
            }
            Load_Data("select * from NHACUNGCAP");
        }
示例#17
0
 /// <summary>
 /// Cập nhật dữ liệu vào bảng: nhacungcap
 /// </summary>
 /// <param name="obj">objnhacungcap</param>
 /// <returns>Trả về trắng: Cập nhật thành công; Trả về khác trắng: Cập nhật không thành công</returns>
 public string Update(nhacungcap objnhacungcap)
 {
     return(objnhacungcapDA.Update(objnhacungcap));
 }
示例#18
0
 /// <summary>
 /// Thêm mới dữ liệu vào bảng: nhacungcap
 /// </summary>
 /// <param name="obj">objnhacungcap</param>
 /// <returns>Trả về trắng: Thêm mới thành công; Trả về khác trắng: Thêm mới không thành công</returns>
 public string Insert(nhacungcap objnhacungcap)
 {
     return(objnhacungcapDA.Insert(objnhacungcap));
 }
示例#19
0
 public nhacungcapBL()
 {
     objnhacungcapDA = new nhacungcap();
 }
示例#20
0
        public bool them_NhaCungCap(nhacungcap ncc)
        {
            string qry = "insert into NhaCungCap(TenNCC, DiaChiNCC, SDTNCC) values(N'" + ncc.TenNCC1 + "', N'" + ncc.DiaChiNCC1 + "', N'" + ncc.SDTNCC1 + "')";

            return(Insert_Update_Delete(qry));
        }
示例#21
0
        public bool update_NhaCungCap(nhacungcap ncc)
        {
            string qry = "update NhaCungCap set TenNCC = N'" + ncc.TenNCC1 + "' ,DiaChiNCC = N'" + ncc.DiaChiNCC1 + "', SDTNCC = N'" + ncc.SDTNCC1 + "' where MNCC='" + ncc.MNCC1 + "'";

            return(Insert_Update_Delete(qry));
        }
示例#22
0
        private void Save()
        {
            string            temploi = "";
            string            loi     = "";
            nhacungcapBL      _ctr    = new nhacungcapBL();
            List <nhacungcap> lst     = new List <nhacungcap>();

            lst = GetData();
            if (lst != null)
            {
                for (int i = 0; i < lst.Count; i++)
                {
                    loi = "";
                    nhacungcap _obj = new nhacungcap();
                    try { _obj = _ctr.GetByID(lst[i].id); }
                    catch { }
                    if (_obj == null)
                    {
                        try { loi = c1FlexGrid1.GetUserData(c1FlexGrid1.FindRow(lst[i].id.ToString().Trim(), 1, c1FlexGrid1.Cols["id"].Index, true, true, true), "ten").ToString().Trim(); }
                        catch { }
                        if (loi.Equals("") == true)
                        {
                            loi = _ctr.Insert(lst[i]);
                            if (loi.Equals("") == false)
                            {
                                c1FlexGrid1.Rows[c1FlexGrid1.FindRow(lst[i].id.ToString().Trim(), 1, c1FlexGrid1.Cols["id"].Index, true, true, true)].Style = cserror;
                            }
                            else
                            {
                                _ctrlog.Append(Data.use, "Thêm mới nhà cung cấp: " + lst[i].ten.Trim());
                            }
                        }
                        else
                        {
                            c1FlexGrid1.Rows[c1FlexGrid1.FindRow(lst[i].id.ToString().Trim(), 1, c1FlexGrid1.Cols["id"].Index, true, true, true)].Style = cserror;
                        }
                        if (loi.Trim().Equals("") == false)
                        {
                            temploi = loi;
                        }
                    }
                    else
                    {
                        try { loi = c1FlexGrid1.GetUserData(c1FlexGrid1.FindRow(lst[i].id.ToString().Trim(), 1, c1FlexGrid1.Cols["id"].Index, true, true, true), "ten").ToString().Trim(); }
                        catch { }
                        if (loi.Equals("") == true)
                        {
                            loi = _ctr.Update(lst[i]);
                            if (loi.Equals("") == false)
                            {
                                c1FlexGrid1.SetUserData(c1FlexGrid1.FindRow(lst[i].id.ToString().Trim(), 1, c1FlexGrid1.Cols["id"].Index, true, true, true), "ten", loi);
                                c1FlexGrid1.Rows[c1FlexGrid1.FindRow(lst[i].id.ToString().Trim(), 1, c1FlexGrid1.Cols["id"].Index, true, true, true)].Style = cserror;
                            }
                            else
                            {
                                _ctrlog.Append(Data.use, "Cập nhật thông tin nhà cung cấp: " + lst[i].ten.Trim());
                            }
                        }
                        else
                        {
                            c1FlexGrid1.SetUserData(c1FlexGrid1.FindRow(lst[i].id.ToString().Trim(), 1, c1FlexGrid1.Cols["id"].Index, true, true, true), "ten", loi);
                            c1FlexGrid1.Rows[c1FlexGrid1.FindRow(lst[i].id.ToString().Trim(), 1, c1FlexGrid1.Cols["id"].Index, true, true, true)].Style = cserror;
                        }
                        if (loi.Trim().Equals("") == false)
                        {
                            temploi = loi;
                        }
                    }
                }
            }
            if (temploi.Trim().Equals("") == true)
            {
                HienThiDS();
                MessageBox.Show("Cập nhật dữ liệu thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Cập nhật dữ liệu không thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#23
0
 public ActionResult Themmoinhacungcap(nhacungcap nhacungcap)
 {
     db.nhacungcaps.InsertOnSubmit(nhacungcap);
     db.SubmitChanges();
     return(RedirectToAction("Nhacungcap"));
 }