//LOST UPDATED SOLVED
        public static int lostUpdatedSolvedXuatNguyenLieu(KhoHang_NguyenLieuDTO dto, int maNhaHang, int mucCoLap)
        {
            DbCommand   command = DataAccessCode.CreateCommand();
            DbParameter param   = command.CreateParameter();

            command.CommandText = "dbo.lostUpdatedSolvedXuatNguyenLieu";
            //// create a new parameter
            param.ParameterName = "@soLuongXuat";
            param.Value         = dto.SoLuongXuat;
            param.DbType        = DbType.Int32;
            command.Parameters.Add(param);
            //// create a new parameter
            param = command.CreateParameter();
            param.ParameterName = "@maNguyenLieu";
            param.Value         = dto.NguyenLieu.MaNguyenLieu;
            param.DbType        = DbType.Int32;
            command.Parameters.Add(param);
            //// create a new parameter
            param = command.CreateParameter();
            param.ParameterName = "@maNhaHang";
            param.Value         = maNhaHang;
            param.DbType        = DbType.Int32;
            command.Parameters.Add(param);
            //// create a new parameter
            param = command.CreateParameter();
            param.ParameterName = "@mucCoLap";
            param.Value         = mucCoLap;
            param.DbType        = DbType.Int32;
            command.Parameters.Add(param);

            return(DataAccessCode.ExecuteNonQuery(command));
        }
예제 #2
0
        private void bt_luuLaiT2_Click_1(object sender, EventArgs e)
        {
            for (int i = 0; i < grid_ds.RowCount; i++)
            {
                if (Convert.ToBoolean(grid_ds.Rows[i].Cells[0].Value) == true)
                {
                    KhoHang_NguyenLieuDTO updateDTO = (KhoHang_NguyenLieuDTO)grid_ds.Rows[i].Cells["cMaNguyenLieu"].Value;
                    layChiTietKhoHangNguyenLieuDTO(updateDTO, i);
                    int kq = KhoHang_NguyenLieuBUS.capNhatChiTietKhoHangNguyenLieuT2(updateDTO, GlobalVariables.maNhaHang);
                    if (kq != 1)
                    {
                        MessageBox.Show("Không cập nhật được dòng thứ " + (i + 1).ToString(), "[!]Thông báo");
                        return;
                    }
                    //MessageBox.Show(kq.ToString());
                    grid_ds.Rows[i].Cells["cLuongXuat"].Value = 0;
                }
            }
            //lam tuoi danh sach sau khi da cap nhat thanh cong
            //lamTuoiDanhSachTraCuuNguyenLieu();

            //GUI.accessory.readOnlyCheckedRows(grid_ds, true);

            //bt_sua.Click += new EventHandler(bt_sua_Click);
        }
        public static KhoHang_NguyenLieuDTO layChiTietKhoHangNguyenLieu(int maNhaHang, NguyenLieuDTO nguyenLieuCanTim)
        {
            DbCommand command = DataAccessCode.CreateCommand();

            command.CommandText = "dbo.layChiTietKhoHangNguyenLieu";
            DbParameter param = command.CreateParameter();

            param.ParameterName = "@MaNguyenLieu";
            param.Value         = nguyenLieuCanTim.MaNguyenLieu;
            param.DbType        = DbType.Int32;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@MaNhaHang";
            param.Value         = maNhaHang;
            param.DbType        = DbType.Int32;
            command.Parameters.Add(param);

            DataTable             dt  = DataAccessCode.ExecuteSelectCommand(command);
            KhoHang_NguyenLieuDTO dto = new KhoHang_NguyenLieuDTO();

            if (dt != null)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dto.NguyenLieu.MaNguyenLieu  = Convert.ToInt32(dt.Rows[i]["MaNguyenLieu"]);
                    dto.NguyenLieu.TenNguyenLieu = dt.Rows[i]["TenNguyenLieu"].ToString();
                    dto.NguyenLieu.DonViTinh     = dt.Rows[i]["DonViTinh"].ToString();
                    dto.SoLuongTon     = Convert.ToInt32(dt.Rows[i]["SoLuongTon"]);
                    dto.SucChua        = Convert.ToInt32(dt.Rows[i]["SucChua"]);
                    dto.MucTonToiThieu = Convert.ToInt32(dt.Rows[i]["MucChuaToiThieu"]);
                }
            }
            return(dto);
        }
예제 #4
0
        private void grid_ds_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
        {
            if (grid_ds.SelectedRows.Count == 0)
            {
                return;
            }
            KhoHang_NguyenLieuDTO dtoPre = (KhoHang_NguyenLieuDTO)grid_ds.CurrentRow.Cells["cMaNguyenLieu"].Value;

            try
            {
                int luongTonPre = dtoPre.SoLuongTon;
                int conTrong    = Convert.ToInt32(grid_ds.CurrentRow.Cells["cToiDa"].Value) - Convert.ToInt32(grid_ds.CurrentRow.Cells["cLuongTon"].Value);
                if (conTrong < 0)
                {
                    MessageBox.Show("Lượng tồn vượt quá Sức Chứa.", "[!]Thông Báo");
                    bt_sua.Enabled            = false;
                    grid_ds.CurrentCell.Value = luongTonPre;
                    return;
                }
                else
                {
                    grid_ds.CurrentRow.Cells["cConTrong"].Value = conTrong;
                    bt_sua.Enabled = true;
                }
            }
            catch (FormatException fe)
            {
                MessageBox.Show(fe.Message);
                return;
            }
        }
예제 #5
0
 //DEADLOCK SOLVED
 public static int deadlockSolvedXuatNguyenLieu(KhoHang_NguyenLieuDTO dto, int maNhaHang)
 {
     if (dto != null && dto.NguyenLieu.MaNguyenLieu != 0 && maNhaHang != 0)
     {
         return(KhoHang_NguyenLieuDAO.deadlockSolvedXuatNguyenLieu(dto, maNhaHang));
     }
     return(0);
 }
예제 #6
0
 //LOST UPDATED SOLVED
 public static int lostUpdatedSolvedXuatNguyenLieu(KhoHang_NguyenLieuDTO dto, int maNhaHang, int mucCoLap)
 {
     if (dto != null && dto.NguyenLieu.MaNguyenLieu != 0 && maNhaHang != 0)
     {
         return(KhoHang_NguyenLieuDAO.lostUpdatedSolvedXuatNguyenLieu(dto, maNhaHang, mucCoLap));
     }
     return(0);
 }
예제 #7
0
 public static int capNhatChiTietKhoHangNguyenLieu(KhoHang_NguyenLieuDTO dto, int maNhaHang)
 {
     if (dto != null && dto.NguyenLieu.MaNguyenLieu != 0 && maNhaHang != 0)
     {
         return(KhoHang_NguyenLieuDAO.capNhatChiTietKhoHangNguyenLieu(dto, maNhaHang));
     }
     return(0);
 }
예제 #8
0
 private void showThongTinKhoHang_NguyenLieuDTOLenGrid(int row, KhoHang_NguyenLieuDTO dto)
 {
     grid_ds.Rows[row].Cells[0].ReadOnly             = false;
     grid_ds.Rows[row].Cells["cMaNguyenLieu"].Value  = dto;
     grid_ds.Rows[row].Cells["cTenNguyenLieu"].Value = dto.NguyenLieu.TenNguyenLieu;
     grid_ds.Rows[row].Cells["cDonViTinh"].Value     = dto.NguyenLieu.DonViTinh;
     grid_ds.Rows[row].Cells["cLuongTon"].Value      = dto.SoLuongTon;
     grid_ds.Rows[row].Cells["cConTrong"].Value      = Convert.ToInt32(dto.SucChua) - Convert.ToInt32(dto.SoLuongTon);
     grid_ds.Rows[row].Cells["cToiThieu"].Value      = dto.MucTonToiThieu;
 }
예제 #9
0
 private bool ingrid_dsOrNot(KhoHang_NguyenLieuDTO dto)
 {
     for (int i = 0; i < grid_ds.RowCount; i++)
     {
         if (dto.NguyenLieu.MaNguyenLieu == ((KhoHang_NguyenLieuDTO)grid_ds.Rows[i].Cells["cMaNguyenLieu"].Value).NguyenLieu.MaNguyenLieu)
         {
             return(true);
         }
     }
     return(false);
 }
예제 #10
0
        private void bt_capNhat_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < grid_ds.RowCount; i++)
            {
                if (Convert.ToBoolean(grid_ds.Rows[i].Cells[0].Value) == true)
                {
                    KhoHang_NguyenLieuDTO updateDTO = (KhoHang_NguyenLieuDTO)grid_ds.Rows[i].Cells["cMaNguyenLieu"].Value;
                    layChiTietKhoHangNguyenLieuDTO(updateDTO, i);
                    int kq = 0;
                    if (updateDTO.SoLuongXuat == 0)
                    {
                        kq = KhoHang_NguyenLieuBUS.capNhatChiTietKhoHangNguyenLieu(updateDTO, GlobalVariables.maNhaHang);
                    }
                    else if (updateDTO.SoLuongXuat > 0)
                    {
                        if (cb_deMoXungDot.SelectedIndex == 0)//LOST UPDATED
                        {
                            kq = KhoHang_NguyenLieuBUS.lostUpdatedXuatNguyenLieu(updateDTO, GlobalVariables.maNhaHang);
                        }
                        else if (cb_deMoXungDot.SelectedIndex == 1)//LOST UPDATED SOLVED
                        {
                            kq = KhoHang_NguyenLieuBUS.lostUpdatedSolvedXuatNguyenLieu(updateDTO, GlobalVariables.maNhaHang, cb_mucCoLap.SelectedIndex);
                        }
                        else if (cb_deMoXungDot.SelectedIndex == 2)//DEADLOCK
                        {
                            kq = KhoHang_NguyenLieuBUS.deadlockXuatNguyenLieu(updateDTO, GlobalVariables.maNhaHang);
                        }
                        else if (cb_deMoXungDot.SelectedIndex == 3)//DEADLOCK SOLVED
                        {
                            kq = KhoHang_NguyenLieuBUS.deadlockSolvedXuatNguyenLieu(updateDTO, GlobalVariables.maNhaHang);
                        }
                        else if (cb_deMoXungDot.SelectedIndex == cb_deMoXungDot.Items.Count - 1)//KHÔNG DÙNG
                        {
                            kq = KhoHang_NguyenLieuBUS.xuatNguyenLieu(updateDTO, GlobalVariables.maNhaHang);
                        }
                    }

                    if (kq != 1)
                    {
                        MessageBox.Show("Không cập nhật được dòng thứ " + (i + 1).ToString(), "[!]Thông báo");
                        return;
                    }
                    grid_ds.Rows[i].Cells["cLuongXuat"].Value = 0;
                }
            }
            //lam tuoi danh sach sau khi da cap nhat thanh cong
            lamTuoiDanhSachTraCuuNguyenLieu();

            //GUI.accessory.readOnlyCheckedRows(grid_ds, true);

            //bt_sua.Click += new EventHandler(bt_sua_Click);
        }
예제 #11
0
        private void layChiTietKhoHangNguyenLieuDTO(KhoHang_NguyenLieuDTO dto, int rowOfGrid)
        {
            //dto.NguyenLieu.TenNguyenLieu = grid_ds.Rows[rowOfGrid].Cells["cTenNguyenLieu"].Value.ToString();
            //quan ly kho ko dc sua ten nguyen lieu, anh huong toi nhung nha hang khac

            dto.SoLuongTon = Convert.ToInt32(grid_ds.Rows[rowOfGrid].Cells["cLuongTon"].Value);
            if (Convert.ToInt32(grid_ds.Rows[rowOfGrid].Cells["cLuongXuat"].Value) != 0)
            {
                dto.SoLuongXuat = Convert.ToInt32(grid_ds.Rows[rowOfGrid].Cells["cLuongXuat"].Value);
            }
            dto.SucChua        = Convert.ToInt32(grid_ds.Rows[rowOfGrid].Cells["cToiDa"].Value);
            dto.MucTonToiThieu = Convert.ToInt32(grid_ds.Rows[rowOfGrid].Cells["cToiThieu"].Value);
            //dto.NguyenLieu.DonViTinh = grid_ds.Rows[rowOfGrid].Cells["cDonViTinh"].Value.ToString();
            //ko dc sua, anh huong toi nha hang khac
        }
예제 #12
0
 private void lamTuoiDanhSachTraCuuNguyenLieu()
 {
     for (int i = 0; i < grid_ds.RowCount; i++)
     {
         KhoHang_NguyenLieuDTO dto = new KhoHang_NguyenLieuDTO();
         //dto.NguyenLieu.MaNguyenLieu = ((KhoHang_NguyenLieuDTO)grid_ds.Rows[i].Cells["cTenNguyenLieu"].Value).NguyenLieu.MaNguyenLieu;
         dto.NguyenLieu.MaNguyenLieu = Convert.ToInt32(grid_ds.Rows[i].Cells["cMaNguyenLieu"].Value.ToString());
         dto = KhoHangBUS.layChiTietKhoHang_NguyenLieu(GlobalVariables.maNhaHang, dto.NguyenLieu);
         if (dto != null)
         {
             //gan lai gia tri moi(neu co thay doi) len dong hien tai
             showThongTinKhoHang_NguyenLieuDTOLenGrid(i, dto);
         }
     }
 }
예제 #13
0
        private void timKiemNguyenLieuGanDung(NguyenLieuDTO nl)
        {
            ArrayList ds = new ArrayList();

            ds = KhoHangBUS.layDSKhoHang_NguyenLieu(GlobalVariables.maNhaHang, nl);
            //MessageBox.Show(ds.Count.ToString());
            for (int i = 0; i < ds.Count; i++)
            {
                KhoHang_NguyenLieuDTO dto = (KhoHang_NguyenLieuDTO)ds[i];
                if (!ingrid_dsOrNot(dto))
                {
                    grid_ds.Rows.Add();
                    showThongTinKhoHang_NguyenLieuDTOLenGrid(grid_ds.RowCount - 1, dto);
                }
            }
        }
        public static int capNhatChiTietKhoHangNguyenLieuT2(KhoHang_NguyenLieuDTO dto, int maNhaHang)
        {
            DbCommand command = DataAccessCode.CreateCommand();

            command.CommandText = "dbo.lostUpdateUpdateChiTietKhoHangNguyenLieuT2";
            //// create a new parameter
            DbParameter param = command.CreateParameter();

            param.ParameterName = "@soLuongTon";
            param.Value         = dto.SoLuongTon;
            param.DbType        = DbType.Int32;
            command.Parameters.Add(param);
            //// create a new parameter
            param = command.CreateParameter();
            param.ParameterName = "@chuaToiDa";
            param.Value         = dto.SucChua;
            param.DbType        = DbType.Int32;
            command.Parameters.Add(param);
            //// create a new parameter
            param = command.CreateParameter();
            param.ParameterName = "@chuaToiThieu";
            param.Value         = dto.MucTonToiThieu;
            param.DbType        = DbType.Int32;
            command.Parameters.Add(param);
            //// create a new parameter
            param = command.CreateParameter();
            param.ParameterName = "@maNguyenLieu";
            param.Value         = dto.NguyenLieu.MaNguyenLieu;
            param.DbType        = DbType.Int32;
            command.Parameters.Add(param);
            //// create a new parameter
            param = command.CreateParameter();
            param.ParameterName = "@maNhaHang";
            param.Value         = maNhaHang;
            param.DbType        = DbType.Int32;
            command.Parameters.Add(param);

            return(DataAccessCode.ExecuteNonQuery(command));
        }
예제 #15
0
        private void showDanhSachNguyenLieuTheoMonAn(MonAnDTO monAn)
        {
            ArrayList dsNguyenLieuTheoMon = new ArrayList();

            dsNguyenLieuTheoMon = MonAnBUS.layDanhSachNguyenLieuTheoMonAn(monAn);


            for (int i = 0; i < dsNguyenLieuTheoMon.Count; i++)
            {
                ArrayList dsKQ = new ArrayList();
                dsKQ = KhoHangBUS.layDSKhoHang_NguyenLieu(GlobalVariables.maNhaHang, ((MonAn_NguyenLieuDTO)dsNguyenLieuTheoMon[i]).NguyenLieu);

                for (int j = 0; j < dsKQ.Count; j++)
                {
                    KhoHang_NguyenLieuDTO dto = (KhoHang_NguyenLieuDTO)dsKQ[j];
                    if (!ingrid_dsOrNot(dto))
                    {
                        grid_ds.Rows.Add();
                        showThongTinKhoHang_NguyenLieuDTOLenGrid(grid_ds.RowCount - 1, dto);
                    }
                }
            }
        }