Ejemplo n.º 1
0
        private void btnAddDetailExport_Click(object sender, EventArgs e)
        {
            int flag = 0;

            if (datagridPackEx2.RowCount <= 1)
            {
                MessageBox.Show("Không thể thêm chi tiết");
            }
            else
            {
                if (txtNewIdOutPut.Text != "" && txtCreateDateOutPut.Text != "" && txtUserOutput.Text != "")
                {
                    OutPutDTO dto = new OutPutDTO(txtNewIdOutPut.Text, txtCreateDateOutPut.Text, txtUserOutput.Text.Substring(0, 10));
                    if (bus.ThemPhieuXuat(dto))
                    {
                        for (int i = 0; i < datagridPackEx2.RowCount - 1; i++)
                        {
                            try
                            {
                                string       masp           = datagridPackEx2.Rows[i].Cells[0].Value.ToString();
                                string       mapackage      = datagridPackEx2.Rows[i].Cells[1].Value.ToString();
                                int          sl             = Int32.Parse(datagridPackEx2.Rows[i].Cells[2].Value.ToString());;
                                string       machitietphieu = txtNewIdOutPut.Text;
                                OutPutDetail dto1           = new OutPutDetail(machitietphieu, masp, mapackage, sl);
                                if (bus.ThemCTPhieuXuat(dto1))
                                {
                                    flag = 1;
                                }
                                else
                                {
                                    flag = 0;
                                }
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("Đã xảy ra lỗi");
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Thêm thất bại");
                    }
                }
                else
                {
                    MessageBox.Show("Không thể thêm");
                }
                if (flag == 1)
                {
                    MessageBox.Show("Thêm thành công chi tiết phiếu xuất hàng");
                }
                else
                {
                    MessageBox.Show("Thêm chi tiết xuất hàng thất bại");
                }
            }
        }
Ejemplo n.º 2
0
        public bool ThemChiTietPhieuXuat(OutPutDetail dto)
        {
            try
            {
                _conn.Open();
                string SQL = string.Format("INSERT INTO DetailOutputProduct(ID, ID_PRODUCT, QUANTITY, ID_Package) VALUES ('{0}', '{1}', {2}, '{3}')", dto.machitietphieu, dto.masp, dto.sl, dto.mapackage);
                Console.WriteLine(SQL);
                SqlCommand cmd = new SqlCommand(SQL, _conn);
                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                _conn.Close();
            }

            return(false);
        }
Ejemplo n.º 3
0
 public bool ThemCTPhieuXuat(OutPutDetail dto)
 {
     return(dal.ThemChiTietPhieuXuat(dto));
 }