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); } } } }
public static int Update(tblCustom customsObj) { dbEcustomEntities _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); _db.Connection.Open(); 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; } finally { _db.Connection.Close(); } }
private void FrmReportImportToReExport_Load(object sender, EventArgs e) { this.Text = "Bao cao xuat/nhap chuyen cua khau" + ConstantInfo.MESSAGE_TITLE + GlobalInfo.CompanyName; //init cbCustoms List<tblCustom> listCustom = CustomsFacory.getAll(); foreach (tblCustom cb in listCustom) { cb.CustomsName = cb.CustomsCode + " - " + cb.CustomsName; } listCustom = listCustom.OrderBy(g => g.CustomsCode).ToList(); tblCustom allObj = new tblCustom(); allObj.CustomsCode = "0"; allObj.CustomsName = "Tất cả"; listCustom.Insert(0, allObj); cbCustoms.DataSource = listCustom; cbCustoms.ValueMember = "CustomsCode"; cbCustoms.DisplayMember = "CustomsName"; //init cbCompany List<tblCompany> listCompany = CompanyFactory.getAllCompany(); foreach (tblCompany cp in listCompany) { cp.CompanyName = cp.CompanyCode + " - " + cp.CompanyName; } listCompany = listCompany.OrderBy(g => g.CompanyCode).ToList(); tblCompany allCompanyObj = new tblCompany(); allCompanyObj.CompanyCode = "0"; allCompanyObj.CompanyName = "Tất cả"; listCompany.Insert(0, allCompanyObj); cbCompany.DataSource = listCompany; cbCompany.ValueMember = "CompanyCode"; cbCompany.DisplayMember = "CompanyName"; }
public static int Insert(tblCustom customs) { dbEcustomEntities _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); _db.Connection.Open(); customs.CreatedDate = CommonFactory.GetCurrentDate(); customs.ModifiedDate = CommonFactory.GetCurrentDate(); customs.BranchId= FDHelper.RgCodeOfUnit(); _db.AddTotblCustoms(customs); try { if (_db.Connection.State == ConnectionState.Closed) _db.Connection.Open(); return _db.SaveChanges(); } catch (Exception ex) { return -1; } finally { _db.Connection.Close(); } }
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; }