예제 #1
0
 public void InitializeControl()
 {
     comboBoxMaCTT.DataSource = bll.GetListMaCTT();
 }
예제 #2
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            // Check textBoxMaTS, textBoxMaCTT == null or duplicated ?
            bool isGoodToGo = true;

            if (String.IsNullOrEmpty(textBoxMaTS.Text.Trim()))
            {
                MessageBox.Show("Nhập lại mã tài sản", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                isGoodToGo = false;
            }
            foreach (object ob in bll.GetListMaTS())
            {
                if (textBoxMaTS.Text.Equals(ob.ToString()))
                {
                    MessageBox.Show("Nhập lại mã tài sản", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    isGoodToGo = false;
                    break;
                }
            }

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

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

            if (isGoodToGo)
            {
                TAISAN myTS = new TAISAN();
                myTS.MaTS           = textBoxMaTS.Text;
                myTS.MaLoaiTS       = bll.GetMaLoaiTS(comboBoxTenLoaiTS.SelectedValue.ToString());
                myTS.MaPhong        = bll.GetMaPhong(comboBox1.SelectedValue.ToString());
                myTS.TenTS          = textBoxTenTS.Text;
                myTS.MaChungTuTang  = textBoxMaCTT.Text;
                myTS.ThongSoKyThuat = textBoxTSKT.Text;
                int tien;
                Int32.TryParse(textBoxThanhTien.Text, out tien);
                myTS.ThanhTien   = tien;
                myTS.SoLuong     = myTS.SoLuongCTT = int.Parse(numericUpDownSoLuong.Value.ToString());
                myTS.TyLeHM      = int.Parse(numericUpDownTyLeHM.Value.ToString());
                myTS.TyLeCL      = int.Parse(numericUpDownTyLeCL.Value.ToString());
                myTS.GhiChu      = textBoxGhiChu.Text;
                myTS.NgayGhiTang = DateTime.Parse(dateTimePickerGhiTang.Value.ToShortDateString());
                myTS.NoiDung     = textBoxNoiDung.Text;
                d.Invoke(myTS);

                this.Close();
                MessageBox.Show("Thêm tài sản thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }