public int InsertNguyenLieu(int mode, VNguyenLieu_DTO nl)
        {
            String store = "SPoV_InsertNguyenLieu"; // che do default

            //Goi store theo Mode
            if (mode == 1) //che do delay
            {
                store = "SPoV_Delay_InsertNguyenLieu";
            }
            else
            if (mode == 3)                             // do che do fix loi chi can thay doi isolation o giao tac khac
            {
                store = "SPoV_Delay_InsertNguyenLieu"; // nen van goi store delay
            }
            CreateCommand_StoreName(store);
            cm.Parameters.Add("@Flag", SqlDbType.Int).Direction = ParameterDirection.Output;
            cm.Parameters.Add("@MaNH", SqlDbType.NChar);
            cm.Parameters.Add("@TenNL", SqlDbType.NVarChar);
            cm.Parameters.Add("@DonVi", SqlDbType.NVarChar);
            cm.Parameters.Add("@SoLuongTon", SqlDbType.Int);

            cm.Parameters["@MaNH"].Value       = nl.MaNH;
            cm.Parameters["@TenNL"].Value      = nl.TenNL;
            cm.Parameters["@DonVi"].Value      = nl.DonVi;
            cm.Parameters["@SoLuongTon"].Value = nl.SoLuongTon;

            ExecuteInsertUpdateDelete();
            return((int)cm.Parameters["@Flag"].Value);
        }
Exemple #2
0
        public frmNguyenLieu_ThemNL()
        {
            InitializeComponent();

            busNguyenLieu = new VNguyenLieu_BUS();
            _nguyenlieu   = new VNguyenLieu_DTO();
        }
 public void CapNhatNguyenLieu()
 {
     if (txtTenNguyenLieu.Text.Trim().Length == 0)
     {
         MessageBox.Show("Bạn chưa nhập Tên Nguyên Liệu !", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtTenNguyenLieu.Focus();
     }
     else
     if (txtDonVi.Text.Trim().Length == 0)
     {
         MessageBox.Show("Bạn chưa nhập đơn vị nguyên liêu!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtDonVi.Focus();
     }
     else
     if (txtSoLuongTon.Text.Trim().Length == 0)
     {
         MessageBox.Show("Bạn chưa nhập số lượng tồn!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtSoLuongTon.Focus();
     }
     else
     {
         VNguyenLieu_DTO temp = new VNguyenLieu_DTO();
         temp.MaNL       = (int)dtNguyenLieu_Source.Rows[stt - 1][0];
         temp.MaNH       = dtNguyenLieu_Source.Rows[stt - 1][1].ToString();
         temp.TenNL      = txtTenNguyenLieu.Text.Trim();
         temp.DonVi      = txtDonVi.Text.Trim();
         temp.SoLuongTon = int.Parse(txtSoLuongTon.Text.Trim());
         try
         {
             if (busNguyenLieu.UpdateNguyenLieu(mode, temp) == 0)
             {
                 DevExpress.XtraEditors.XtraMessageBox.Show("Cập nhật không thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 LoadNguyenLieu();
                 DevExpress.XtraEditors.XtraMessageBox.Show("Đã cập nhật lại dử liệu", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         catch (Exception)
         {
             DevExpress.XtraEditors.XtraMessageBox.Show("Cập nhật không thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }
        public int UpdateNguyenLieu(int mode, VNguyenLieu_DTO nl)
        {
            String store = "SPoV_UpdateNguyenLieu";

            CreateCommand_StoreName(store);
            cm.Parameters.Add("@Flag", SqlDbType.Int).Direction = ParameterDirection.Output;
            cm.Parameters.Add("@MaNL", SqlDbType.Int);
            cm.Parameters.Add("@MaNH", SqlDbType.NChar);
            cm.Parameters.Add("@TenNL", SqlDbType.NVarChar);
            cm.Parameters.Add("@DonVi", SqlDbType.NVarChar);
            cm.Parameters.Add("@SoLuongTon", SqlDbType.Int);

            cm.Parameters["@MaNL"].Value       = nl.MaNL;
            cm.Parameters["@MaNH"].Value       = nl.MaNH;
            cm.Parameters["@TenNL"].Value      = nl.TenNL;
            cm.Parameters["@DonVi"].Value      = nl.DonVi;
            cm.Parameters["@SoLuongTon"].Value = nl.SoLuongTon;

            ExecuteInsertUpdateDelete();
            return((int)cm.Parameters["@Flag"].Value);
        }
        private List <VNguyenLieu_DTO> ConvertToList(DataTable dt)
        {
            List <VNguyenLieu_DTO> ls = new List <VNguyenLieu_DTO>();

            foreach (DataRow row in dt.Rows)
            {
                VNguyenLieu_DTO nguyenlieu = new VNguyenLieu_DTO();
                nguyenlieu.MaNL       = (int)row.ItemArray[0];
                nguyenlieu.MaNH       = row.ItemArray[1].ToString();
                nguyenlieu.TenNL      = row.ItemArray[2].ToString();
                nguyenlieu.DonVi      = row.ItemArray[3].ToString();
                nguyenlieu.SoLuongTon = (int)row.ItemArray[4];
                try
                {
                    nguyenlieu.Gia = (double)row.ItemArray[5];
                }
                catch (Exception) {}
                ls.Add(nguyenlieu);
            }
            return(ls);
        }
 public int UpdateNguyenLieu(int mode, VNguyenLieu_DTO nl)
 {
     return(daoNguyenLieu.UpdateNguyenLieu(mode, nl));
 }
 public int InsertNguyenLieu(int mode, VNguyenLieu_DTO nl)
 {
     return(daoNguyenLieu.InsertNguyenLieu(mode, nl));
 }