private void buttonOK_Click(object sender, EventArgs e)
        {
            bool isGoodToGo = true;


            if (String.IsNullOrEmpty(textBoxMaCTG.Text.Trim()))
            {
                MessageBox.Show("Nhập lại mã chứng từ giảm", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                isGoodToGo = false;
            }

            foreach (string ob in bll.GetListMaCTT_BLL())
            {
                if (textBoxMaCTG.Text.Equals(ob.ToString()))
                {
                    MessageBox.Show("Nhập lại mã chứng từ giảm", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    isGoodToGo = false;
                    break;
                }
            }

            if (isGoodToGo)
            {
                DTO.ChungTuGiam myTS = new DTO.ChungTuGiam();
                //string mats= bll.GetMTS_BLL(bll.GetMaPhong_BLL(cbbPhong.SelectedItem.ToString()), cbbTenTS.SelectedItem.ToString());
                string matsruong = bll.GetMaTSTruong_BLL(cbbTenTS.SelectedItem.ToString());
                string mats      = matsruong.Substring(0, 3) + "-" + bll.GetMaKhoa_BLL(cbbKhoa.SelectedItem.ToString()) + "-" + bll.GetMaPhong_BLL(cbbPhong.SelectedItem.ToString());
                myTS.MaTaiSan      = mats;
                myTS.MaChungTuGiam = textBoxMaCTG.Text.ToString();
                myTS.SoLuong       = int.Parse(numericUpDownSoLuong.Value.ToString());
                myTS.NgayGhiGiam   = dateTimePickerGhiGiam.Value;
                myTS.ThanhTien     = 10 * int.Parse(numericUpDownSoLuong.Value.ToString());
                myTS.NoiDung       = textBoxNoiDung.Text;
                myTS.GhiChu        = textBoxGhiChu.Text;
                bll.AddChungTuGiam_BLL(myTS);
                int slPhong = bll.GetSL_BLL(mats) - myTS.SoLuong;
                bll.UpdateSL(mats, slPhong, slPhong * 10);
                d();

                this.Close();
                MessageBox.Show("Thêm tài sản thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#2
0
        private void buttonTim_Click(object sender, EventArgs e)
        {
            string id    = " ";
            string tents = textBoxTim.Text.ToString();

            try
            {
                id = bll.GetMaTSTruong_BLL(tents);
                string FirstIdPhong = id.Substring(0, 3);
                dgvTS.DataSource = null;
                dgvTS.DataSource = bll.SearchTS_BLL(cbbKhoa.SelectedItem.ToString(), cbbPhong.SelectedItem.ToString(), FirstIdPhong);
                stt(dgvTS);
                MessageBox.Show("Da thuc hien tim!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Khong ton tai ten tai san nay,vui long kiem tra lai!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#3
0
      private void buttonOK_Click(object sender, EventArgs e)
      {
          if (cbbMTS.SelectedItem.ToString() == null)
          {
              this.Close();
              MessageBox.Show("Tài sản chưa nhâp về kho lấy đâu mà nhập cho khoa !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
          }
          else
          {
              bool   have    = false;
              TaiSan k       = bll.GetInfoAdd_BLL(bll.GetMaTSTruong_BLL(cbbMTS.SelectedItem.ToString()));
              string phandau = bll.GetMaTSTruong_BLL(cbbMTS.SelectedItem.ToString()).Substring(0, 3);
              mats = phandau + "-" + bll.GetMaKhoa_BLL(cbbKhoa.SelectedItem.ToString()) + "-" + "000";
              foreach (object ob in bll.GetListMaTS_BLL())
              {
                  if (mats.Equals(ob.ToString()))
                  {
                      have = true;
                      int sl = Convert.ToInt32(numericUpDownSoLuong.Value) + bll.GetSL_BLL(mats);
                      bll.UpdateSL(mats, sl, sl * 10);
                      int slTruong = bll.GetSL_BLL(bll.GetMaTSTruong_BLL(cbbMTS.SelectedItem.ToString())) - Convert.ToInt32(numericUpDownSoLuong.Value);

                      bll.UpdateSL(bll.GetMaTSTruong_BLL(cbbMTS.SelectedItem.ToString()), slTruong, slTruong * 10);
                      bll.updateSLNhap_DAL(mats, bll.GetSLnhap_BLL(mats) + Convert.ToInt32(numericUpDownSoLuong.Value));
                      d();
                      this.Close();
                      MessageBox.Show("tài sản này đã có trong khoa,update số lượng thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                  }
              }
              if (have == false)
              {
                  k.MaTaiSan    = mats;
                  k.GhiChu      = "Phan Vat Tu Ve Khoa";
                  k.ThanhTien   = Convert.ToInt32(numericUpDownSoLuong.Value) * 10;
                  k.SoLuong     = Convert.ToInt32(numericUpDownSoLuong.Value);
                  k.SoLuongNhap = Convert.ToInt32(numericUpDownSoLuong.Value);
                  bll.AddTS_BLL(k);
                  int slTruong = bll.GetSL_BLL(bll.GetMaTSTruong_BLL(cbbMTS.SelectedItem.ToString())) - k.SoLuong;

                  bll.UpdateSL(bll.GetMaTSTruong_BLL(cbbMTS.SelectedItem.ToString()), slTruong, slTruong * 10);
                  d();
                  this.Close();
                  MessageBox.Show("Thêm tài sản  vào khoa thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
              }
          }
      }