Ejemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DebtDetail detail = new DebtDetail();

            if (!string.IsNullOrWhiteSpace(txtThanhtien.Text) || DateTime.Compare(dtpPaymentDay.DateTime, UtilityFunction.minDate) > 0)
            {
                detail.SetCreate();
                //detail.Payment = CurrencyUtility.ToDecimal(txtThanhtien.Text);
                //detail.PaymentDate = UtilityFunction.GetDatetime(dtpPaymentDay);
                //detail.RequestPaymentCode = txtReqCode.Text;
                //detail.Note = txtNote.Text;
                detail.DebtId = m_Debt.DebtId;
                CoverObjectUtility.GetAutoBindingData(this, detail);
                //detail.DebtDetailId = string.IsNullOrWhiteSpace(txtDetailId.Text)==false? Convert.ToInt32(txtDetailId.Text):0;
            }
            else
            {
                detail = null;
            }
            m_Debt.Bill = txtBill.Text;
            try
            {
                using (IUnitOfWork uow = new UnitOfWork())
                {
                    if (detail != null)
                    {
                        DebtDetail exist = uow.DebtDetailRepository.Find(detail.DebtDetailId);
                        if (exist == null)
                        {
                            uow.DebtDetailRepository.Add(detail);
                            gridUtility.AddNewRow <DebtDetail>(detail);
                        }
                        else
                        {
                            uow.DebtDetailRepository.Update(detail);
                            gridUtility.UpdateRow <DebtDetail>(detail);
                        }
                    }
                    uow.DebtRepository.Update(m_Debt);
                    uow.Commit();
                }
                m_Debt.TotalPayment += detail.Payment;
                if (UpdateRow != null)
                {
                    UpdateRow(m_Debt, CRUD.Update);
                }
                gridView1.RefreshData();
            }
            catch
            {
            }
        }
Ejemplo n.º 2
0
 private void btnCreate_Click(object sender, EventArgs e)
 {
     if (ValidationUtility.FieldNotAllowNull(txtCompanyCode) == false)
     {
         lblNotify1.SetText(UI.hasnoinfomation, LabelNotify.EnumStatus.Failed);
         return;
     }
     m_Company = new Company();
     CoverObjectUtility.GetAutoBindingData(this.tableLayoutPanel1, m_Company);
     m_Company.ApproveStatusId = (int)ApproveStatus.Wait;
     m_Company.SetCreate();
     m_Company.CompanyId = 0;
     try
     {
         var count = 0;
         using (IUnitOfWork uow = new UnitOfWork())
         {
             count = uow.CompanyRepository.CheckExitCompany(m_Company);
         }
         if (count > 0)
         {
             lblNotify1.SetText(UI.CompanyisExists, ToolBoxCS.LabelNotify.EnumStatus.Failed);
             return;
         }
         SaveCompany(m_Company);
         lblNotify1.SetText(UI.success, ToolBoxCS.LabelNotify.EnumStatus.Success);
         gridUtility2.AddNewRow <Company>(m_Company);
     }
     catch
     {
         lblNotify1.SetText(UI.failed, ToolBoxCS.LabelNotify.EnumStatus.Failed);
     }
 }
Ejemplo n.º 3
0
 private void InsertOrUpdate(Model.Bank bank, Utility.CRUD cru, Model.BrankBank branch = null)
 {
     if (bank != null && branch == null)
     {
         if (cru == CRUD.Insert)
         {
             gridUtility1.AddNewRow(bank);
         }
         if (cru == CRUD.Update)
         {
             gridUtility1.UpdateRow(bank);
         }
     }
     if (branch != null && bank != null)
     {
         if (cru == CRUD.Insert)
         {
             gridUtility2.AddNewRow(branch);
         }
         if (cru == CRUD.Update)
         {
             gridUtility2.UpdateRow(branch);
         }
     }
 }
Ejemplo n.º 4
0
 private void btnCreateAccount_Click(object sender, EventArgs e)
 {
     if (ValidationUtility.FieldNotAllowNull(groupSubsupplier) == false)
     {
         lblNotify1.SetText(UI.hasnoinfomation, LabelNotify.EnumStatus.Failed);
         return;
     }
     if (m_User == null)
     {
         m_User = new Users();
     }
     CoverObjectUtility.GetAutoBindingData(groupSubsupplier, m_User);
     if (string.IsNullOrWhiteSpace(m_User.Password))
     {
         m_User.Password = UtilityFunction.GetSHA256Hash(m_User.UserName);
     }
     m_User.UserId = 0;
     if (m_User == null)
     {
         return;
     }
     try
     {
         SaveAccount(m_User);
         lblNotify1.SetText(UI.success, LabelNotify.EnumStatus.Success);
         gridUtility1.AddNewRow <SubSupplier>(m_Subsupplier);
     }
     catch
     {
         lblNotify1.SetText(UI.failed, LabelNotify.EnumStatus.Failed);
     }
 }
Ejemplo n.º 5
0
 public void addNewRow(Category category)
 {
     if (category == null)
     {
         return;
     }
     gridUtility.AddNewRow <Category>(category);
 }
Ejemplo n.º 6
0
 private void AddRow(Department department)
 {
     if (department == null)
     {
         return;
     }
     gridUtility.AddNewRow <Department>(department);
     gridControl1.RefreshDataSource();
 }
Ejemplo n.º 7
0
 private void AddOrUpdateRow(Model.Material material, CRUD flag)
 {
     if (flag == CRUD.Insert)
     {
         gridUtility.AddNewRow <Model.Material>(material);
     }
     else
     {
         gridUtility.UpdateRow <Model.Material>(material);
     }
 }
Ejemplo n.º 8
0
 private void AddOrUpdate(Model.Po PO, CRUD flag)
 {
     if (flag == CRUD.Insert)
     {
         gridUtility.AddNewRow <Po>(PO);
     }
     else
     {
         gridUtility.UpdateRow <Po>(PO);
     }
 }
Ejemplo n.º 9
0
 private void AddOrUpdate(ProductType unit, CRUD crud)
 {
     if (crud == CRUD.Insert)
     {
         gridUtility.AddNewRow(unit);
     }
     if (crud == CRUD.Update)
     {
         gridUtility.UpdateRow(unit);
     }
     gridControl1.RefreshDataSource();
 }
Ejemplo n.º 10
0
 private void InsertOrUpdate(NoteProjectDetail note, CRUD cru)
 {
     if (cru == CRUD.Insert)
     {
         gridUtility.AddNewRow(note);
     }
     else
     {
         gridUtility.UpdateRow(note);
     }
     gridView1.RefreshData();
 }
Ejemplo n.º 11
0
 private void InsertOrUpdate(Project pro, CRUD cru)
 {
     if (cru == CRUD.Insert)
     {
         utility.AddNewRow(pro);
     }
     else
     {
         utility.UpdateRow(pro);
     }
     gridView1.RefreshData();
 }
Ejemplo n.º 12
0
 private void InsertOrUpdate(StaffPosition staffPosition, CRUD crud)
 {
     if (crud == CRUD.Insert)
     {
         utility.AddNewRow(staffPosition);
     }
     else
     {
         utility.UpdateRow(staffPosition);
     }
     gridView1.RefreshData();
 }
Ejemplo n.º 13
0
 private void InsertOrUpdate(PaymentMethod pm, CRUD cru)
 {
     if (cru == CRUD.Insert)
     {
         gridUtility.AddNewRow(pm);
     }
     else
     {
         gridUtility.UpdateRow(pm);
     }
     gridView1.RefreshData();
 }
Ejemplo n.º 14
0
 private void InsertOrUpdate(Model.CurrencyUnit cu, Utility.CRUD cru)
 {
     if (cru == Utility.CRUD.Insert)
     {
         utility.AddNewRow(cu);
     }
     else
     {
         utility.UpdateRow(cu);
     }
     gridView4.RefreshData();
 }
Ejemplo n.º 15
0
 private void SaveProduct()
 {
     if (!string.IsNullOrWhiteSpace(pictureBox2.PictureOriginPath))
     {
         PictureUtility.SaveImg(pictureBox2.PictureOriginPath);
     }
     if (!string.IsNullOrWhiteSpace(txtInstallGuide.FilePath))
     {
         FileUtility.SaveToServer(txtInstallGuide.FileName, txtInstallGuide.FilePath);
     }
     if (!string.IsNullOrWhiteSpace(txtDatasheet.Text))
     {
         FileUtility.SaveToServer(txtDatasheet.FileName, txtDatasheet.FilePath);
     }
     if (!string.IsNullOrWhiteSpace(txtCard3D.FilePath))
     {
         FileUtility.SaveToServer(txtCard3D.FileName, txtCard3D.FilePath);
     }
     if (!string.IsNullOrWhiteSpace(txtDimension.FilePath))
     {
         PictureUtility.SaveImg(txtDimension.FilePath);
     }
     using (IUnitOfWork uow = new UnitOfWork())
     {
         if (m_Product.ProductId == Guid.Empty)
         {
             uow.ProductRepository.Add(m_Product);
             gridUtility.AddNewRow <Product>(m_Product);
         }
         else
         {
             uow.ProductRepository.Update(m_Product);
             gridUtility.UpdateRow <Product>(m_Product);
         }
         if (displayMultiplePicture1.ImgList != null)
         {
             for (int i = 0; i < displayMultiplePicture1.ImgList.Length; i++)
             {
                 if (!string.IsNullOrWhiteSpace(displayMultiplePicture1.ImgList[i]))
                 {
                     ProductPicture picture = new ProductPicture();
                     picture.ProductId = m_Product.ProductId;
                     picture.Picture   = displayMultiplePicture1.ImgList[i];
                     uow.ProductPictureRepository.Add(picture);
                 }
             }
         }
         uow.Commit();
     }
 }
Ejemplo n.º 16
0
 private void AddOrUpdateRow(Quotation quotation, CRUD crud)
 {
     if (quotation == null)
     {
         return;
     }
     if (crud == CRUD.Insert)
     {
         gridUtility.AddNewRow <Quotation>(quotation);
     }
     if (crud == CRUD.Update)
     {
         gridUtility.UpdateRow <Quotation>(quotation);
     }
 }
Ejemplo n.º 17
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Model.Material material = searchLookUpEdit1.EditValue as Model.Material;
            if (material == null)
            {
                return;
            }
            material.MaterialQuantity = Convert.ToInt32(txtQuantity.Text);
            material.ProductId        = m_Product.ProductId;
            IList <Model.Material> lstMaterial     = gridControl1.DataSource as IList <Model.Material>;
            ProductMaterial        productmaterial = null;

            Model.Material exists = null;
            try
            {
                using (IUnitOfWork uow = new UnitOfWork())
                {
                    if (lstMaterial != null)
                    {
                        exists = lstMaterial.Where(p => p.MaterialId == material.MaterialId && p.ProductId == material.ProductId).FirstOrDefault();
                    }
                    if (exists != null)
                    {
                        exists.MaterialQuantity         += material.MaterialQuantity;
                        productmaterial                  = new ProductMaterial();
                        productmaterial.ProductId        = m_Product.ProductId;
                        productmaterial.MaterialId       = exists.MaterialId;
                        productmaterial.MaterialQuantity = exists.MaterialQuantity;
                        uow.MaterialRepository.UpdateProductMaterial(productmaterial);
                    }
                    else
                    {
                        productmaterial                  = new ProductMaterial();
                        productmaterial.ProductId        = m_Product.ProductId;
                        productmaterial.MaterialId       = material.MaterialId;
                        productmaterial.MaterialQuantity = material.MaterialQuantity;
                        uow.MaterialRepository.AddProductMaterial(productmaterial);
                    }
                    uow.Commit();
                }
                gridUtility.AddNewRow <Model.Material>(material);
                labelNotify1.SetText(UI.success, ToolBoxCS.LabelNotify.EnumStatus.Failed);
            }
            catch
            {
                labelNotify1.SetText(UI.failed, ToolBoxCS.LabelNotify.EnumStatus.Failed);
            }
        }
Ejemplo n.º 18
0
 private void Add(IncomeExpense sug)
 {
     gridUtility.AddNewRow(sug);
 }
Ejemplo n.º 19
0
 private void AddnewRow(Department department)
 {
     gridUtility3.AddNewRow <Department>(department);
     gridControl1.RefreshDataSource();
 }