Esempio n. 1
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (_mode == 0)
     {
         //validate
         if (validate())
         {
             tblCustom customs = new tblCustom();
             customs.CustomsCode = txtCode.Text;
             customs.CustomsName = txtName.Text.Trim();
             customs.Description = txtDescription.Text.Trim();
             customs.CreatedBy   = _userInfo.UserID;
             customs.ModifiedBy  = _userInfo.UserID;
             if (CustomsFacory.Insert(customs) > 0)
             {
                 try
                 {
                     _frmListCustoms.init();
                 }
                 catch (Exception ex)
                 {
                     //do nothing
                 }
                 MessageBox.Show("Thêm mới đơn vị hải quan thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 reset();
             }
             else
             {
                 MessageBox.Show("Thêm mới đơn vị hải quan không thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
Esempio n. 2
0
        private void FrmAddCustoms_Load(object sender, EventArgs e)
        {
            if (_mode == 0) //add new
            {
                this.Text         = "Them moi don vi hai quan" + ConstantInfo.MESSAGE_TITLE + GlobalInfo.CompanyName;
                btnAdd.Enabled    = true;
                btnUpdate.Enabled = false;
            }

            if (_mode == 1) //update
            {
                btnAdd.Enabled    = false;
                btnUpdate.Enabled = true;

                this.Text = "Cap nhat don vi hai quan" + ConstantInfo.MESSAGE_TITLE + GlobalInfo.CompanyName;
                tblCustom customs = CustomsFacory.FindByCode(_customsCode);
                if (customs == null)
                {
                    MessageBox.Show("Đơn vị hải quan này không còn tồn tại trong Cơ Sở Dữ Liệu. Bạn hãy kiểm tra lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                txtCode.ReadOnly    = true;
                txtCode.Text        = customs.CustomsCode;
                txtName.Text        = customs.CustomsName;
                txtDescription.Text = customs.Description;
            }
        }
Esempio n. 3
0
        public static int Update(tblCustom customsObj)
        {
            var db = new dbTrainEntities(ConnectionController.GetConnection());

            tblCustom originCustoms = db.tblCustoms.Where(g => g.CustomsCode == customsObj.CustomsCode).FirstOrDefault();

            if (originCustoms == null)
            {
                return(-1);
            }

            originCustoms.CustomsName  = customsObj.CustomsName;
            originCustoms.Description  = customsObj.Description;
            originCustoms.ModifiedBy   = customsObj.ModifiedBy;
            originCustoms.ModifiedDate = CommonFactory.GetCurrentDate();

            try
            {
                return(db.SaveChanges());
            }
            catch (Exception ex)
            {
                return(-1);
            }
        }
Esempio n. 4
0
 public ActionResult EditHome([Bind(Include = "Custom_ID,ct_01,ct_02,ct_03,ct_04,ct_05,ct_06")] tblCustom custom)
 {
     if (ModelState.IsValid)
     {
         db.Entry(custom).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
     return(View(custom));
 }
Esempio n. 5
0
        public static int Insert(tblCustom customs)
        {
            var db = new dbTrainEntities(ConnectionController.GetConnection());

            customs.CreatedDate  = CommonFactory.GetCurrentDate();
            customs.ModifiedDate = CommonFactory.GetCurrentDate();

            db.AddTotblCustoms(customs);

            return(db.SaveChanges());
        }
Esempio n. 6
0
        private void frmReport_Load(object sender, EventArgs e)
        {
            this.Location = new Point((_mainForm.Width - this.Width) / 2, (_mainForm.Height - this.Height) / 2);
            var list   = new List <tblCustom>();
            var custom = new tblCustom {
                CustomsCode = "0", CustomsName = "Tất cả"
            };

            list.Add(custom);

            //tao danh sach don vi hai quan
            var listtblCustoms = CustomsFacory.getAll();

            list.AddRange(listtblCustoms.Select(item => new tblCustom {
                CustomsCode = item.CustomsCode.Trim(), CustomsName = item.CustomsName
            }));

            cbUnit.DisplayMember = "CustomsName";
            cbUnit.ValueMember   = "CustomsCode";
            cbUnit.DataSource    = list;
            if (FDHelper.RgGetSizeOfUnit() == ConstantInfo.Branch)
            {
                String unitCode = FDHelper.RgCodeOfUnit();
                cbUnit.SelectedValue = unitCode;
                cbUnit.Enabled       = false;
            }

            //tao danh sach loai hinh
            List <tblType> listType = new List <tblType>();
            tblType        type     = new tblType();

            type.TypeCode = "";
            type.TypeName = "Tất cả";
            listType.Add(type);
            foreach (tblType obj in TypeFactory.getAllType())
            {
                tblType typeObj = new tblType();
                typeObj.TypeName = obj.TypeCode + " - " + obj.TypeName;
                typeObj.TypeCode = obj.TypeCode;
                listType.Add(typeObj);
            }
            cbType.DisplayMember = "TypeName";
            cbType.ValueMember   = "TypeCode";
            cbType.DataSource    = listType;
        }
Esempio n. 7
0
        private bool validate()
        {
            bool valid = true;

            if (_mode == 0)//add new
            {
                if (String.IsNullOrEmpty(txtCode.Text.Trim()))
                {
                    valid = false;
                    MessageBox.Show("Mã đơn vị hải quan không được để trống", "Dữ liệu không hợp lệ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtCode.Focus();
                }
                else if (null != CustomsFacory.FindByCode(txtCode.Text.Trim()))
                {
                    valid = false;
                    MessageBox.Show("Mã đơn vị hải quan này đã tồn tại, hãy thử với mã khác", "Dữ liệu không hợp lệ", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                    txtCode.Focus();
                }

                if (String.IsNullOrEmpty(txtName.Text.Trim()))
                {
                    valid = false;
                    MessageBox.Show("Tên đơn vị hải quan không được để trống", "Dữ liệu không hợp lệ", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                    txtName.Focus();
                }
            }
            if (_mode == 1) //update
            {
                tblCustom customs = CustomsFacory.FindByCode(_customsCode);
                if (customs == null)
                {
                    valid = false;
                    MessageBox.Show("Đơn vị hải quan này không còn tồn tại trong Cơ Sở Dữ Liệu. Bạn hãy kiểm tra lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (String.IsNullOrEmpty(txtName.Text.Trim()))
                {
                    valid = false;
                    MessageBox.Show("Tên đơn vị hải quan không được để trống", "Dữ liệu không hợp lệ", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                    txtName.Focus();
                }
            }
            return(valid);
        }
 public void AddTotblCustoms(tblCustom tblCustom)
 {
     AddObject("tblCustoms", tblCustom);
 }
 public static tblCustom CreatetblCustom(string customsCode, string branchId)
 {
     tblCustom tblCustom = new tblCustom();
     tblCustom.CustomsCode = customsCode;
     tblCustom.BranchId = branchId;
     return tblCustom;
 }
Esempio n. 10
0
        // GET: Admin/Setting
        public ActionResult EditHome()
        {
            tblCustom custom = db.tblCustoms.Find(1);

            return(View(custom));
        }