Пример #1
0
        private void txtQuantity_TextChanged(object sender, EventArgs e)
        {
            int     soluong   = string.IsNullOrWhiteSpace(txtQuantity.Text) == true ? 0 : Convert.ToInt32(txtQuantity.Text);
            decimal thanhtien = soluong * CurrencyUtility.ToDecimal(txtQuotationPrice.Text);

            txtThanhtien.Text = CurrencyUtility.DecimalToString(thanhtien);
        }
Пример #2
0
 private static object ChangeType(object obj, Type t)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(obj.ToString()))
         {
             if (t == typeof(int))
             {
                 return((int)(0));
             }
             if (t == typeof(double))
             {
                 return((double)(0));
             }
             if (t == typeof(decimal))
             {
                 return((decimal)(0));
             }
             if (t == typeof(float))
             {
                 return((float)(0));
             }
         }
         if ((t == typeof(decimal) || t == typeof(Decimal)))
         {
             return(CurrencyUtility.ToDecimal(obj.ToString()));
         }
         return(Convert.ChangeType(obj, t));
     }
     catch
     {
         obj = "";
         return(ChangeType(obj, t));
     }
 }
Пример #3
0
        private void txtThanhtien_TextChanged(object sender, EventArgs e)
        {
            decimal val = CurrencyUtility.ToDecimal(txtThanhtien.Text);

            txtThanhtien.Text           = CurrencyUtility.DecimalToString(val);
            txtThanhtien.SelectionStart = txtThanhtien.Text.Length;
        }
Пример #4
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (m_QuotationDetail.Quotation.ApproveStatusId == (int)ApproveStatus.Approved)
     {
         lblNotify1.SetText(UI.itemwasapproved, ToolBoxCS.LabelNotify.EnumStatus.Failed);
         return;
     }
     if (m_Product == null)
     {
         return;
     }
     using (IUnitOfWork uow = new UnitOfWork())
     {
         m_Product = uow.ProductRepository.Find(m_Product.ProductId);
         uow.Commit();
     }
     if (m_Product == null)
     {
         lblNotify1.SetText(UI.productnotfound, ToolBoxCS.LabelNotify.EnumStatus.Failed);
         return;
     }
     m_QuotationDetail.ProductId = m_Product.ProductId;
     m_QuotationDetail.Product   = m_Product;
     m_QuotationDetail.Quantity  = string.IsNullOrWhiteSpace(txtQuantity.Text) == true ? 0 : Convert.ToInt32(txtQuantity.Text);
     if (m_QuotationDetail.Quantity == 0)
     {
         lblNotify1.SetText(UI.hasnotquantity, ToolBoxCS.LabelNotify.EnumStatus.Failed);
         return;
     }
     m_QuotationDetail.QuotationPrice = CurrencyUtility.ToDecimal(txtQuotationPrice.Text);
     m_QuotationDetail.BasePrice      = CurrencyUtility.ToDecimal(txtPrice.Text);
     if (m_QuotationDetail.QuotationPrice == 0)
     {
         lblNotify1.SetText(UI.hasnotprice, ToolBoxCS.LabelNotify.EnumStatus.Failed);
         return;
     }
     CoverObjectUtility.GetAutoBindingData(this, m_QuotationDetail);
     try
     {
         using (IUnitOfWork uow = new UnitOfWork())
         {
             uow.QuotationDetailRepository.Update(m_QuotationDetail);
             uow.Commit();
         }
         if (UpdateRow != null)
         {
             UpdateRow(m_QuotationDetail);
         }
         this.Close();
     }
     catch
     {
         lblNotify1.SetText(UI.updatefailed, ToolBoxCS.LabelNotify.EnumStatus.Failed);
     }
 }
Пример #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidationUtility.FieldNotAllowNull(this) == false)
            {
                return;
            }
            if (m_Quotation == null)
            {
                return;
            }
            CoverObjectUtility.GetAutoBindingData(this, m_Quotation);
            if (m_Quotation.ApproveStatusId == (int)ApproveStatus.Approved)
            {
                lblNotify1.SetText(UI.itemwasapproved, ToolBoxCS.LabelNotify.EnumStatus.Failed);
                return;
            }
            m_Quotation.SetModify();
            IList <QuotationDetail> lstQuotationDetail = gridControl1.DataSource as IList <QuotationDetail>;

            try
            {
                using (IUnitOfWork uow = new UnitOfWork())
                {
                    uow.QuotationRepository.Update(m_Quotation);
                    foreach (QuotationDetail p in lstQuotationDetail)
                    {
                        p.QuotationCode = m_Quotation.QuotationCode;
                        if (p.QuotationDetailId != Guid.Empty)
                        {
                            uow.QuotationDetailRepository.Update(p);
                        }
                        else
                        {
                            uow.QuotationDetailRepository.Add(p);
                        }
                    }
                    uow.Commit();
                }
                m_Quotation.TotalValue = CurrencyUtility.ToDecimal(colThanhtien.SummaryText);
                isEdited = false;
                if (UpdateRow != null)
                {
                    UpdateRow(m_Quotation);
                }
                lblNotify1.SetText(UI.success, ToolBoxCS.LabelNotify.EnumStatus.Success);
            }
            catch
            {
                lblNotify1.SetText(UI.failed, ToolBoxCS.LabelNotify.EnumStatus.Failed);
            }
        }
Пример #6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidationUtility.FieldNotAllowNull(this) == false)
            {
                return;
            }
            if (m_Quotation == null)
            {
                return;
            }
            CoverObjectUtility.GetAutoBindingData(this.tableLayoutPanel1, m_Quotation);
            IList <QuotationDetail> lstQuottionDetail = gridControl1.DataSource as IList <QuotationDetail>;

            if (lstQuottionDetail == null)
            {
                return;
            }

            m_Quotation.Company    = m_Company;
            m_Quotation.TotalValue = CurrencyUtility.ToDecimal(colThanhtien.SummaryText);
            try
            {
                using (IUnitOfWork uow = new UnitOfWork())
                {
                    uow.QuotationRepository.Add(m_Quotation);
                    foreach (QuotationDetail quotationDetail in lstQuottionDetail)
                    {
                        quotationDetail.QuotationCode = m_Quotation.QuotationCode;
                        uow.QuotationDetailRepository.Add(quotationDetail);
                    }
                    uow.Commit();
                }
                if (AddRow != null)
                {
                    AddRow(m_Quotation, CRUD.Insert);
                }
                lblNotify1.SetText(UI.createsuccess, ToolBoxCS.LabelNotify.EnumStatus.Success);
                //();
                isEdited = false;
                this.Close();
            }
            catch
            {
                lblNotify1.SetText(UI.createfailed, ToolBoxCS.LabelNotify.EnumStatus.Failed);
            }
        }
Пример #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (m_Product == null)
            {
                return;
            }
            m_QuotationDetail = new QuotationDetail();
            using (IUnitOfWork uow = new UnitOfWork())
            {
                m_Product = uow.ProductRepository.Find(m_Product.ProductId);
                uow.Commit();
            }
            if (m_Product == null)
            {
                lblNotify1.SetText(UI.productnotfound, ToolBoxCS.LabelNotify.EnumStatus.Failed);
                return;
            }
            m_QuotationDetail.ProductId = m_Product.ProductId;
            m_QuotationDetail.Product   = m_Product;
            m_QuotationDetail.Quantity  = string.IsNullOrWhiteSpace(txtQuantity.Text) == true ? 0 : Convert.ToInt32(txtQuantity.Text);
            if (m_QuotationDetail.Quantity == 0)
            {
                lblNotify1.SetText(UI.hasnotquantity, ToolBoxCS.LabelNotify.EnumStatus.Failed);
                return;
            }
            m_QuotationDetail.QuotationPrice = CurrencyUtility.ToDecimal(txtQuotationPrice.Text);
            m_QuotationDetail.BasePrice      = CurrencyUtility.ToDecimal(txtPrice.Text);
            if (m_QuotationDetail.QuotationPrice == 0)
            {
                lblNotify1.SetText(UI.hasnotprice, ToolBoxCS.LabelNotify.EnumStatus.Failed);
                return;
            }
            CoverObjectUtility.GetAutoBindingData(this, m_QuotationDetail);

            if (SaveSelectedProperty != null)
            {
                SaveSelectedProperty(m_QuotationDetail);
            }
            ((Form)this.TopLevelControl).Close();
        }
Пример #8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidationUtility.FieldNotAllowNull(this) == false)
            {
                return;
            }
            IList <QuotationDetail> lstProduct = gridControl1.DataSource as IList <QuotationDetail>;

            if (m_Po == null)
            {
                return;
            }
            if (lstProduct == null)
            {
                return;
            }
            CoverObjectUtility.GetAutoBindingData(this.tableLayoutPanel3, m_Po);
            try
            {
                using (IUnitOfWork uow = new UnitOfWork())
                {
                    uow.PoRepository.Add(m_Po);
                    uow.Commit();
                }
                isEdited = false;
                lblNotify1.SetText(UI.createsuccess, ToolBoxCS.LabelNotify.EnumStatus.Success);
                if (AddRow != null)
                {
                    m_Po.Quantity   = Convert.ToInt32(colQuantity.SummaryText);
                    m_Po.TotalValue = CurrencyUtility.ToDecimal(colThanhtien.SummaryText);
                    AddRow(m_Po, CRUD.Insert);
                }
                Close();
            }
            catch
            {
                lblNotify1.SetText(UI.createfailed, ToolBoxCS.LabelNotify.EnumStatus.Failed);
            }
        }
Пример #9
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (m_Po.ApproveStatusId == (int)ApproveStatus.Approved)
     {
         lblNotify1.SetText(UI.itemwasapproved, ToolBoxCS.LabelNotify.EnumStatus.Failed, 5000);
         return;
     }
     if (ValidationUtility.FieldNotAllowNull(this.tableLayoutPanel3) == false)
     {
         return;
     }
     if (m_Po == null)
     {
         return;
     }
     CoverObjectUtility.GetAutoBindingData(this.tableLayoutPanel3, m_Po);
     m_Po.Quantity   = Convert.ToInt32(colQuantity.SummaryText);
     m_Po.TotalValue = CurrencyUtility.ToDecimal(colThanhtien.SummaryText);
     m_Po.SetModify();
     try
     {
         using (IUnitOfWork uow = new UnitOfWork())
         {
             uow.PoRepository.Update(m_Po);
             uow.Commit();
         }
         lblNotify1.SetText(UI.updatesuccess, ToolBoxCS.LabelNotify.EnumStatus.Success);
         isEdited = false;
         if (UpdateRow != null)
         {
             UpdateRow(m_Po, CRUD.Update);
         }
     }
     catch
     {
         lblNotify1.SetText(UI.updatefailed, ToolBoxCS.LabelNotify.EnumStatus.Failed);
     }
 }
Пример #10
0
 private void txtMoneyBack_TextChanged(object sender, EventArgs e)
 {
     txtReturnMoneyNumWrite.Text = MoneyToString.ReadMoney.MoneyToText(CurrencyUtility.ToDecimal(txtMoneyBack.Text));
 }
Пример #11
0
 private void txtMoneyOut_TextChanged(object sender, EventArgs e)
 {
     //AutoTextBox text = sender as AutoTextBox;
     //txtMoneyNumWrite.Text = Translate(text.Text).Normalize();
     txtMoneyNumWrite.Text = MoneyToString.ReadMoney.MoneyToText(CurrencyUtility.ToDecimal(txtMoneyOut.Text));
 }
Пример #12
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidationUtility.FieldNotAllowNull(this) == false)
            {
                return;
            }
            if (cbbCategory.SelectedValue == null || cbbSubCate.SelectedValue == null || cbbSerie.SelectedValue == null)
            {
                lblNotify1.SetText(UI.hasnoinfomation, LabelNotify.EnumStatus.Failed);
                return;
            }
            Product product = new Product();

            FormUtility.BindTextBoxToObj <Product>(this, product);
            product.SeriesId    = int.Parse(cbbSerie.SelectedValue.ToString());
            product.ProductCode = txtCode.Text;
            product.ProductName = txtName.Text;
            //product.BranchOfLed = txtLed.Text;
            //product.IPRate = txtIPRate.Text;
            product.DataSheet  = ValidationUtility.StringIsNull(txtDatasheet.Text) == false ? txtDatasheet.Text : "";
            product.Note       = txtNote.Text;
            product.CreateBy   = UserManagement.UserSession.UserName;
            product.CreateDate = DateTime.Now;
            ProductPrice productPrice = new ProductPrice();

            productPrice.Price      = CurrencyUtility.ToDecimal(txtPrice.Text);
            productPrice.ActiveDate = DateTime.Today;
            productPrice.CreateBy   = UserManagement.UserSession.UserName;
            productPrice.CreateDate = DateTime.Now;
            if (ptPicture.Tag != null)
            {
                product.PhotoPath = PictureUtility.SaveImg(ptPicture.Tag.ToString());
            }
            if (ptPhotometer.Tag != null)
            {
                product.PhotoMeter = PictureUtility.SaveImg(ptPhotometer.Tag.ToString());
            }
            try
            {
                using (IUnitOfWork uow = new UnitOfWork())
                {
                    Product exists = uow.ProductRepository.FindByCode(product.ProductCode);
                    if (exists != null)
                    {
                        lblNotify1.SetText(UI.codehasexist, LabelNotify.EnumStatus.Failed);
                        uow.Commit();
                        return;
                    }
                    if (product.Barcode != null)
                    {
                        exists = uow.ProductRepository.FindByBarcode(product.Barcode);
                        if (exists != null)
                        {
                            lblNotify1.SetText(UI.barcodehasexists, LabelNotify.EnumStatus.Failed);
                            uow.Commit();
                            return;
                        }
                    }

                    //Guid id = uow.ProductRepository.Add(product);
                    //product.ProductId = id;
                    ////product.Barcode = BarcodeUtility.generateBarcode(id);
                    //productPrice.ProductId = id;
                    //uow.ProductPriceRepository.Update(productPrice);
                    //uow.ProductRepository.Update(product);
                    //uow.Commit();
                }
                lblNotify1.SetText(UI.createsuccess, LabelNotify.EnumStatus.Success);
            }
            catch
            {
                lblNotify1.SetText(UI.createfailed, LabelNotify.EnumStatus.Failed);
            }
        }