Exemple #1
0
        public bool suaCTPN(DTO_CTPhieuNhap tv)
        {
            try
            {
                // Ket noi
                connect.Open();

                // Query string
                string SQL = string.Format("UPDATE CTPN " +
                                           "SET MASP = '{1}', SOLUONG = {2}, THANHTIEN = {3} " +
                                           "WHERE  MAPN= '{0}' ",
                                           tv.MAPN, tv.MASP, tv.SOLUONG, tv.THANHTIEN);

                // Command (mặc định command type = text nên chúng ta khỏi fải làm gì nhiều).
                SqlCommand cmd = new SqlCommand(SQL, connect);

                // Query và kiểm tra
                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
            }
            finally
            {
                // Dong ket noi
                connect.Close();
            }

            return(false);
        }
Exemple #2
0
        public bool themCTPN(DTO_CTPhieuNhap tv)// THẮNG
        {
            try
            {
                // Ket noi
                connect.Open();


                string SQL = string.Format("INSERT INTO CTPN(MAPN,MASP,SOLUONG,THANHTIEN) " +
                                           "VALUES ('{0}', '{1}', {2} , {3} )",
                                           tv.MAPN, tv.MASP, tv.SOLUONG, tv.THANHTIEN);// DỮ LIỆU NHẬP VÀO

                // Command (mặc định command type = text nên chúng ta khỏi fải làm gì nhiều).
                SqlCommand cmd = new SqlCommand(SQL, connect);

                // Query và kiểm tra
                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
            }
            finally
            {
                // Dong ket noi
                connect.Close();
            }

            return(false);
        }
        private void pictureBox3_Click(object sender, EventArgs e)
        {
            Stelia_BUS.Stelia_BUS bus = new Stelia_BUS.Stelia_BUS();
            if (dataGridView1.Rows.Count == 0)
            {
                PushNoti noti1 = new PushNoti("Error", "Chưa có chi tiết phiếu nhập!");
                noti1.Width = this.Width;
                this.Controls.Add(noti1);
                noti1.Show();
                noti1.ShowNoti();
            }
            DTO_PhieuNhap PN    = new DTO_PhieuNhap(txtMaPN.Text, txtMaNCC.Text, DateChange.ToString(dateNgNhap.DateTime), "0", "0", richTextBox1.Text);
            string        error = CheckThongTin.check_Nhap(PN);

            if (error != "")
            {
                PushNoti noti1 = new PushNoti("Error", error);
                noti1.Width = this.Width;
                this.Controls.Add(noti1);
                noti1.Show();
                noti1.ShowNoti();
                return;
            }
            if (bus.themData(PN) == false)
            {
                PushNoti noti1 = new PushNoti("Error", "Thêm phiếu nhập không thành công!");
                noti1.Width = this.Width;
                this.Controls.Add(noti1);
                noti1.Show();
                noti1.ShowNoti();
                return;
            }
            int SL = 0;
            int GT = 0;

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                DTO_CTPhieuNhap ctpn = new DTO_CTPhieuNhap(PN.MAPN, row.Cells[0].Value.ToString(), row.Cells[2].Value.ToString(), row.Cells[3].Value.ToString());
                SL += int.Parse(row.Cells[2].Value.ToString());
                GT += int.Parse(row.Cells[3].Value.ToString());
                DTO_SanPham[] sp = bus.search_SANPHAM(row.Cells[0].Value.ToString());
                sp[0].SLUONG = (int.Parse(sp[0].SLUONG) + int.Parse(row.Cells[2].Value.ToString())).ToString();
                bus.suaData(sp[0]);
                bus.themData(ctpn);
            }
            PN.TONGSL   = SL.ToString();
            PN.TONGTIEN = GT.ToString();
            bus.suaData(PN);
            DialogResult = DialogResult.OK;
            Close();
        }
Exemple #4
0
 public bool suaData(DTO_CTPhieuNhap tv)
 {
     return(ctpn.suaCTPN(tv));
 }
Exemple #5
0
 public bool themData(DTO_CTPhieuNhap tv)
 {
     return(ctpn.themCTPN(tv));
 }