コード例 #1
0
ファイル: SanPhamDao.cs プロジェクト: fuko9x/OrderApp
        public void updateSanPhamChiTiet(SanPhamDto dto)
        {
            String strQuery = "UPDATE SAN_PHAM_CHI_TIET SET"
                              + " TEN_SAN_PHAM = @tenSP"
                              + ", LOAI_BIA = @loaiBia"
                              + ", LOAI_GIAY = @loaiGiay"
                              + ", SIZE = @size"
                              + ", DON_GIA = @donGia"
                              + ", DESCRIPTION = @decription"
                              + ", NUM_PAGE_DEFAULT = @numPageDefault"
                              + ", ADDITIONAL_PAGES_COST = @addPageCost"
                              + " WHERE id = @id";

            SqlCommand cmd = new SqlCommand(strQuery);

            cmd.CommandType = CommandType.Text;
            cmd.Connection  = Connection.getConnection();
            cmd.Parameters.AddWithValue("@id", dto.id);
            cmd.Parameters.AddWithValue("@tenSP", dto.name);
            cmd.Parameters.AddWithValue("@loaiBia", dto.loaiBia);
            cmd.Parameters.AddWithValue("@loaiGiay", dto.loaiGiay);
            cmd.Parameters.AddWithValue("@size", dto.size);
            cmd.Parameters.AddWithValue("@donGia", dto.donGia);
            cmd.Parameters.AddWithValue("@decription", dto.notes);
            cmd.Parameters.AddWithValue("@numPageDefault", dto.numPageDefault);
            cmd.Parameters.AddWithValue("@addPageCost", dto.addPageCost);
            cmd.ExecuteNonQuery();
        }
コード例 #2
0
ファイル: SearchProduct.cs プロジェクト: fuko9x/OrderApp
        private void btnClone_Click(object sender, EventArgs e)
        {
            if (dataGridViewSanPham.SelectedRows.Count > 0)
            {
                int rowSelected = dataGridViewSanPham.SelectedRows[0].Index;

                SanPhamDto dto = new SanPhamDto();
                //Ten Loai san pham
                dto.idSanPhamCha = int.Parse(cbbLoaiSanPham.SelectedValue.ToString());
                dto.name         = dataGridViewSanPham.Rows[rowSelected].Cells["TEN_SAN_PHAM"].Value.ToString();
                dto.loaiBia      = dataGridViewSanPham.Rows[rowSelected].Cells["LOAI_BIA"].Value.ToString();
                dto.loaiGiay     = dataGridViewSanPham.Rows[rowSelected].Cells["LOAI_GIAY"].Value.ToString();
                dto.size         = dataGridViewSanPham.Rows[rowSelected].Cells["SIZE"].Value.ToString();
                dto.notes        = dataGridViewSanPham.Rows[rowSelected].Cells["DESCRIPTION"].Value.ToString();
                double.TryParse(dataGridViewSanPham.Rows[rowSelected].Cells["DON_GIA"].Value.ToString(), out dto.donGia);
                int.TryParse(dataGridViewSanPham.Rows[rowSelected].Cells["NUM_PAGE_DEFAULT"].Value.ToString(), out dto.numPageDefault);
                double.TryParse(dataGridViewSanPham.Rows[rowSelected].Cells["ADDITIONAL_PAGES_COST"].Value.ToString(), out dto.addPageCost);

                AddProduct frmProduct = new AddProduct();
                frmProduct.cloneProduct(dto);
                frmProduct.ShowDialog(this);

                reloadData();
            }
        }
コード例 #3
0
ファイル: SearchProduct.cs プロジェクト: fuko9x/OrderApp
        public SearchProduct()
        {
            InitializeComponent();
            formatControl();

            sanPhamSelected = new SanPhamDto();
            loadData();
        }
コード例 #4
0
        public async Task <IActionResult> Add([FromBody] SanPhamDto sanPhamDto)
        {
            int idSeller = User.GetIdSeller();

            if (await sanPhamService.Add(idSeller, mapper.Map <SanPham>(sanPhamDto)))
            {
                return(Ok());
            }
            return(BadRequest());
        }
コード例 #5
0
 public static void MappingSanPham(this SanPhamDto spdto, SanPham sp)
 {
     // sp.product_id = spdto.product_id;
     sp.product_type_id = spdto.product_type_id;
     sp.name            = spdto.name;
     sp.amount          = spdto.amount;
     sp.price           = spdto.price;
     sp.description     = spdto.description;
     sp.img             = spdto.img.Replace(Constants.apiUrlImg, "");
     sp.status          = spdto.status;
 }
コード例 #6
0
        public void SanPham_Update(SanPhamDto SPdto)
        {
            var sp = SPcontext.SanPham_GetById(SPdto.product_id);

            if (sp == null)
            {
                return;
            }
            SPdto.MappingSanPham(sp);
            SPcontext.SanPham_Update(sp);
        }
コード例 #7
0
        public async Task <IActionResult> Update(int id, [FromBody] SanPhamDto sanPhamDto)
        {
            int     idSeller = 1; //User.GetIdSeller();
            SanPham sanPham  = mapper.Map <SanPham>(sanPhamDto);

            sanPham.ID = id;
            if (await sanPhamService.Update(idSeller, sanPham))
            {
                return(Ok());
            }
            return(BadRequest());
        }
コード例 #8
0
 public void cloneProduct(SanPhamDto dto)
 {
     this.comboBoxLoaiSanPham.SelectedValue = dto.idSanPhamCha;
     this.currentMode          = CONS_MODE_ADD;
     this.tenSanPham.Text      = dto.name;
     this.loaiBia.Text         = dto.loaiBia;
     this.loaiGiay.Text        = dto.loaiGiay;
     this.size.Text            = dto.size;
     this.description.Text     = dto.notes;
     this.donGia.Text          = dto.donGia.ToString();
     this.numPageDefault.Value = dto.numPageDefault;
     this.addPageCost.Text     = dto.addPageCost.ToString();
 }
コード例 #9
0
 public static SanPham MappingSanPham(this SanPhamDto spdto)
 {
     return(new SanPham {
         product_id = spdto.product_id,
         product_type_id = spdto.product_type_id,
         name = spdto.name,
         amount = spdto.amount,
         price = spdto.price,
         description = spdto.description,
         img = spdto.img.Replace(Constants.apiUrlImg, ""),
         status = spdto.status
     });
 }
コード例 #10
0
ファイル: ProductLogic.cs プロジェクト: fuko9x/OrderApp
        public LogicResult addProduct(FormAddProductObj frmObj)
        {
            SanPhamDao dao = new SanPhamDao();

            if (frmObj.idSanPhamCha == 0)
            {
                SanPhamDto sanPhamdto = new SanPhamDto();
                sanPhamdto.nameSanPhamCha = frmObj.tenSanPhamCha;

                frmObj.idSanPhamCha = dao.insertSanPham(sanPhamdto);
            }
            dao.insertSanPhamChiTiet(createSanPhamChiTietDto(frmObj));
            return(new LogicResult(Contanst.MSG_INFO, AppUtils.getAppConfig("MSGINFO003"), null));
        }
コード例 #11
0
ファイル: SanPhamDao.cs プロジェクト: fuko9x/OrderApp
        public int insertSanPham(SanPhamDto dto)
        {
            String strQuery = "INSERT INTO SAN_PHAM (TEN_SAN_PHAM, NOTES) OUTPUT INSERTED.ID"
                              + " VALUES ("
                              + " @tenSP"
                              + ", @notes )";
            SqlCommand cmd = new SqlCommand(strQuery);

            cmd.CommandType = CommandType.Text;
            cmd.Connection  = Connection.getConnection();
            cmd.Parameters.AddWithValue("@tenSP", dto.nameSanPhamCha);
            cmd.Parameters.AddWithValue("@notes", dto.noteSanPhamCha);
            int idInserted = (int)cmd.ExecuteScalar();

            return(idInserted);
        }
コード例 #12
0
ファイル: ProductLogic.cs プロジェクト: fuko9x/OrderApp
        private SanPhamDto createSanPhamChiTietDto(FormAddProductObj frmObj)
        {
            SanPhamDto dto = new SanPhamDto();

            dto.idSanPhamCha   = frmObj.idSanPhamCha;
            dto.id             = frmObj.idSanPham;
            dto.name           = frmObj.tenSanPham;
            dto.loaiBia        = frmObj.loaiBia;
            dto.loaiGiay       = frmObj.loaiGiay;
            dto.size           = frmObj.size;
            dto.donGia         = frmObj.donGia;
            dto.notes          = frmObj.description;
            dto.numPageDefault = frmObj.numPageDefault;
            dto.addPageCost    = frmObj.addPageCost;
            return(dto);
        }
コード例 #13
0
        public void editProduct(SanPhamDto dto)
        {
            this.Text = "CẬP NHẬT SẢN PHẨM ID: #" + dto.id;
            this.comboBoxLoaiSanPham.SelectedValue = dto.idSanPhamCha;
            this.id.Text              = dto.id.ToString();
            this.currentMode          = CONS_MODE_EDIT;
            this.tenSanPham.Text      = dto.name;
            this.loaiBia.Text         = dto.loaiBia;
            this.loaiGiay.Text        = dto.loaiGiay;
            this.size.Text            = dto.size;
            this.description.Text     = dto.notes;
            this.donGia.Text          = dto.donGia.ToString();
            this.numPageDefault.Value = dto.numPageDefault;
            this.addPageCost.Text     = dto.addPageCost.ToString();

            this.comboBoxLoaiSanPham.DropDownStyle = ComboBoxStyle.DropDownList;
            //this.comboBoxLoaiSanPham.Visible = false;
        }
コード例 #14
0
        public IHttpActionResult Add(SanPhamDto sanPham)
        {
            if (sanPham == null)
            {
                return(NotFound());
            }

            var newSanPham = new SanPham()
            {
                TenSP  = sanPham.TenSanPham,
                GiaMua = sanPham.GiaSanPham
            };

            db.SanPhams.Add(newSanPham);
            db.SaveChanges();

            return(Ok(newSanPham.MaSP));
        }
コード例 #15
0
ファイル: SanPhamDao.cs プロジェクト: fuko9x/OrderApp
        public void insertSanPhamChiTiet(SanPhamDto dto)
        {
            String strQuery = "INSERT INTO SAN_PHAM_CHI_TIET ("
                              + "ID_SAN_PHAM"
                              + ", TEN_SAN_PHAM"
                              + ", LOAI_BIA"
                              + ", LOAI_GIAY"
                              + ", SIZE"
                              + ", DON_GIA"
                              + ", DESCRIPTION"
                              + ", NUM_PAGE_DEFAULT"
                              + ", ADDITIONAL_PAGES_COST"
                              + ") VALUES ("
                              + " @idSanPhamCha"
                              + ", @tenSP"
                              + ", @loaiBia "
                              + ", @loaiGiay "
                              + ", @size "
                              + ", @donGia "
                              + ", @decription "
                              + ", @numPageDefault "
                              + ", @addPageCost "
                              + ")";
            SqlCommand cmd = new SqlCommand(strQuery);

            cmd.CommandType = CommandType.Text;
            cmd.Connection  = Connection.getConnection();
            cmd.Parameters.AddWithValue("@idSanPhamCha", dto.idSanPhamCha);
            cmd.Parameters.AddWithValue("@tenSP", dto.name);
            cmd.Parameters.AddWithValue("@loaiBia", dto.loaiBia);
            cmd.Parameters.AddWithValue("@loaiGiay", dto.loaiGiay);
            cmd.Parameters.AddWithValue("@size", dto.size);
            cmd.Parameters.AddWithValue("@donGia", dto.donGia);
            cmd.Parameters.AddWithValue("@decription", dto.notes);
            cmd.Parameters.AddWithValue("@numPageDefault", dto.numPageDefault);
            cmd.Parameters.AddWithValue("@addPageCost", dto.addPageCost);
            cmd.ExecuteNonQuery();
        }
コード例 #16
0
        public void Tao(
            string productName,
            string description,
            string information,
            string danhmucsp,
            string guaranteeTime,
            string productStatus,
            string brand,
            string memory,
            string network,
            string sim,
            string waterproof,
            string screen,
            string system,
            string ram,
            string frontCam,
            string behindCam,
            string bluetooth,
            string battery,
            string color,
            string sellPrice,
            string price,
            string discountPrice
            )
        {
            CauHinhDto cauhinh = new CauHinhDto();

            cauhinh.ThuongHieu    = brand;
            cauhinh.BoNho         = memory;
            cauhinh.Mang          = network;
            cauhinh.Sim           = sim;
            cauhinh.ChongThamNuoc = waterproof;
            cauhinh.KTManHinh     = screen;
            cauhinh.HeDieuHanh    = system;
            cauhinh.Ram           = ram;
            cauhinh.CMRTruoc      = frontCam;
            cauhinh.CMRSau        = behindCam;
            cauhinh.GPS           = "co";
            cauhinh.Bluetooth     = bluetooth;
            cauhinh.Pin           = battery;

            List <PhanLoaiSPDto> dsphanloaisp = new List <PhanLoaiSPDto>();
            PhanLoaiSPDto        phanloaisp   = new PhanLoaiSPDto();

            phanloaisp.SoLuong = 1;
            phanloaisp.GiaKM   = Double.Parse(discountPrice);
            phanloaisp.GiaBan  = Double.Parse(sellPrice);
            phanloaisp.GiaGoc  = Double.Parse(price);
            phanloaisp.Mau     = color;

            dsphanloaisp.Add(phanloaisp);

            SanPhamDto sp = new SanPhamDto();

            sp.Ten           = productName;
            sp.IDDanhMuc     = 1;
            sp.Mota          = description;
            sp.NoiDung       = information;
            sp.Hinh          = "";
            sp.HinhCT        = "";
            sp.ThoiGianBH    = 12;
            sp.TinhTrangHang = true;
            sp.CauHinh       = cauhinh;
            sp.PhanLoaiSP    = dsphanloaisp;

            var sp1 = JsonConvert.SerializeObject(sp);
            var uri = "http://localhost:57233/api/sanpham/add";

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:57233/api/sanpham/add");

                //HTTP POST
                var postTask = client.PostAsJsonAsync <SanPhamDto>("product", sp);
                postTask.Wait();

                var result = postTask.Result;
            }

            ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator.");
        }
コード例 #17
0
        public ActionResult <SanPhamDto> AddSPDto(SanPhamDto SP)
        {
            this.sanPhamService.SanPham_Add(SP);

            return(CreatedAtAction(nameof(GetSPDto), new { id = SP.product_id }, SP));
        }
コード例 #18
0
 public void UpdateSPDto([FromBody] SanPhamDto SP)
 {
     sanPhamService.SanPham_Update(SP);
 }
コード例 #19
0
        public void SanPham_Add(SanPhamDto SPdto)
        {
            var sp = SPdto.MappingSanPham();

            SPcontext.SanPham_Add(sp);
        }