Exemplo n.º 1
0
        public DocumentPaymentData(int DocumentID, CashRegister _CashRegister)
        {
            InitializeComponent();

            cashRegister = _CashRegister;
            manager = new ContextManager();
            DocumentsLogic dl = new DocumentsLogic(manager);

            document = dl.Get(DocumentID);
            documentSuma = document.DocumentSum;
            documentId = DocumentID;
            PayDateDTP.Value = DateTime.Now;
            DocumentSumaL.Text = Convert.ToString(documentSuma);
            CheckNumberTB.Text = document.Number;
            Fill();
            FillPaymentTypes();
            FillStructureObjects();

            ConfigurationParametersLogic config = new ConfigurationParametersLogic(manager);
            ConfigurationParameter param0 = config.Get(ParametersLogic.Parameter.PAYMENTS_SHOW_CARD.ToString());
            if (param0 != null)
            {
                if (Helpers.ConfigDataTypeConverter.ConvertToBoolean(param0.Value) == true)
                {
                    tableLayoutPanel1.RowStyles[4].SizeType = SizeType.Absolute;

                    tableLayoutPanel1.RowStyles[4].Height = 0;
                }
            }
        }
Exemplo n.º 2
0
        public DocumentDetailsData(string _mode, WareDocument document, List<WareDocumentDetail> documentDetails, WareDocumentDetail documentDetail)
        {
            InitializeComponent();
            manager = new ContextManager();
            mode = _mode;
            MessageL.Text = "";

            Document = document;
            DocumentDetails = documentDetails;
            DocumentDetail = documentDetail;

            FillWares();
            FillPriceGroups();
            FillCurrencies();
            Fill();
            if (mode == "edit")
            {

            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Конструктор форми створення і редагування документу
        /// </summary>
        /// <param name="_mode">режим - new або edit</param>
        /// <param name="_id">ыдентифыкатор документу для режиму редагування</param>
        /// <param name="_CashRegister">підключений принтер чеків(якщо немає то null)</param>
        public DocumentData(string _mode, int? _id, CashRegister _CashRegister)
        {
            InitializeComponent();
            cashRegister = _CashRegister;
            CompasLogger.Add(String.Format("Start opening doc form"), CompasLogger.Level.Info);
            manager = new ContextManager();
            mode = _mode;

            id = _id;
            DetailsGV.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
            FillPayments();
            documentDetailsNew = new List<WareDocumentDetail>();
            documentDetailsOld = new List<WareDocumentDetail>();
            documentDetailsDeleted = new List<WareDocumentDetail>();
            employeesDetailsView = new List<StaffEmployeeView>();
            documentsLogic = new DocumentsLogic(manager);
            documentDetailsLogic = new DocumentDetailsLogic(manager);
            if (mode == "new")
            {
                //створюємо документ в памяті
                document = documentsLogic.CreateEmpty();
            }

            if (mode == "edit")
            {
                //витягуємо документ в память
                document = documentsLogic.Get(Convert.ToInt32(id));
                //витягуємо детальну інформацію по документу
                documentDetailsOld = documentDetailsLogic.GetAll(id);
                documentDetailsView = documentDetailsOld;
                FillEmployeeDetails();

            }
            CompasLogger.Add(String.Format("p1"), CompasLogger.Level.Info);
            Fill();

            CompasLogger.Add(String.Format("End opening doc form"), CompasLogger.Level.Info);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Збереження даних документу
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveBt_Click(object sender, EventArgs e)
        {
            if (dxValidationProvider1.Validate() == true)
            {

                if (ContractorLUE.EditValue != null)
                    document.ContractorID = Convert.ToInt32(ContractorLUE.EditValue);
                if (CurrencyLUE.EditValue != null)
                    document.CurrencyID = Convert.ToInt32(CurrencyLUE.EditValue);
                if (DateDE.EditValue != null)
                    document.Date = Convert.ToDateTime(DateDE.EditValue);

                document.Description = DescriptionTE.Text;
                document.Address = AddressTE.Text;
                document.Number = NumberTE.Text;
                if (DocumentTypeLUE.EditValue != null)
                    document.DocumentTypeID = Convert.ToInt32(DocumentTypeLUE.EditValue);
                if (FromObjectLUE.EditValue != null)
                    document.FromStructureObjectID = Convert.ToInt32(FromObjectLUE.EditValue);
                if (ToObjectLUE.EditValue != null)
                    document.ToStructureObjectD = Convert.ToInt32(ToObjectLUE.EditValue);

                int enterpriseId = Convert.ToInt32(EnterprisesCB.SelectedValue);

                int? teamId = null;
                if (TeamsLUE.EditValue != null)
                    teamId = Convert.ToInt32(TeamsLUE.EditValue);

                //перезаписуємо дані працівників
                documentsLogic.DeleteDocumentEmployees(document, employeesDetailsView);
                foreach (StaffEmployeeView item in employeesDetailsView)
                {

                    documentsLogic.SaveDocumentWithEmployees(document, item.Employee, teamId, mode);
                }

                if (cardId != null)
                    document.CardID = cardId;

                document.DocumentSum = documentSum;
                document.EnterpriseID = enterpriseId;
                if (mode == "new")
                {
                    document.CreatedDate = DateTime.Now;
                    document.CreatedUserID = Compas.Logic.Security.CurrentSecurityContext.Identity.ID;
                    int userId = Compas.Logic.Security.CurrentSecurityContext.Identity.ID;
                    Logic.Staff.StaffEmployeeLogic staffLogic = new Logic.Staff.StaffEmployeeLogic(manager);
                    StaffEmployee employee = staffLogic.GetByUserID(userId);
                    if (employee != null)
                        document.CreatedEmployeeID = employee.ID;

                    //foreach (WareDocumentDetail detail in documentDetailsNew)
                    //{
                    //    documentDetailsLogic.SaveDocumentDetail(detail);
                    //}
                    documentsLogic.SaveDocumentWithDetails(document, documentDetailsView, "new");

                }
                if (mode == "edit")
                {
                    documentDetailsLogic.DeleteAllForDocument(document.ID);
                    documentsLogic.SaveDocumentWithDetails(document, documentDetailsView, "edit");
                    //documentsLogic.
                }

                //якщо вказані дані про авто до перевіряємо чи дані вже існують
                string carNumber = CarNumberTE.Text;
                if (carNumber.Trim().Length > 0)
                {
                    CWCarsLogic carsLogic = new CWCarsLogic(manager);

                    CWCar car = null;
                    categoryId = null;
                    if (CarCategoriesCB.SelectedItem != null)
                    {
                        if (Convert.ToInt32(CarCategoriesCB.SelectedValue) > 0)
                            categoryId = Convert.ToInt32(CarCategoriesCB.SelectedValue);
                    }
                    List<CWCar> cars = carsLogic.GetAll(CarNumberTE.Text, modelId, brandId);
                    if (cars.Count > 0)
                    {
                        car = cars.FirstOrDefault();
                    }
                    else
                    {
                        car = carsLogic.Create(brandId, modelId, carNumber, categoryId);
                    }

                    if (ContractorLUE.EditValue != null)
                    {
                        CWContractorCarsLogic contractorCars = new CWContractorCarsLogic(manager);
                        contractorCars.Create(Convert.ToInt32(document.ContractorID), car);
                    }

                    DocumentCarsLogic documentCarsLogic = new DocumentCarsLogic(manager);
                    documentCarsLogic.Create(document, car);
                }

                //Зберігаємо зміни
                manager.Save();

                //Здійснюємо перерахунок залишків
                Compas.Logic.Wares.WareRemainsLogic remainsLogic = new Compas.Logic.Wares.WareRemainsLogic(manager);
                foreach (WareDocumentDetail detail in documentDetailsView)
                {
                    if (document.FromStructureObjectID != null)
                        remainsLogic.UpdateCurrentRemainByDocumentDetail(document.Date, detail.WareID, document.FromStructureObjectID, null);
                    if (document.ToStructureObjectD != null)
                        remainsLogic.UpdateCurrentRemainByDocumentDetail(document.Date, detail.WareID, document.ToStructureObjectD, null);
                }

                manager.Save();
                int documentId = document.ID;
                if (AddPaymentCB.Checked == true)
                {
                    DocumentPaymentData paymentForm = new DocumentPaymentData(documentId, document, cashRegister);
                    paymentForm.ShowDialog();
                }

                if (CloseAfterPayment == true)
                    this.Close();
                else
                {
                    //після збереження даного документу - позиції документа очищаються і форма готова для створення нового документа
                    CompasLogger.Add(String.Format("Start opening doc form"), CompasLogger.Level.Info);
                    manager = new ContextManager();

                    DetailsGV.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
                    //FillPayments();
                    documentDetailsNew = new List<WareDocumentDetail>();
                    documentDetailsOld = new List<WareDocumentDetail>();
                    documentDetailsDeleted = new List<WareDocumentDetail>();
                    documentDetailsView = new List<WareDocumentDetail>();
                    employeesDetailsView = new List<StaffEmployeeView>();
                    documentsLogic = new DocumentsLogic(manager);
                    documentDetailsLogic = new DocumentDetailsLogic(manager);
                    if (mode == "new")
                    {
                        //створюємо документ в памяті
                        document = documentsLogic.CreateEmpty();
                    }
                    documentDetailsViewer.Clear();
                    FillDetails();
                }
            }
        }