Ejemplo 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;
                }
            }
        }
Ejemplo n.º 2
0
        public DocumentsAlternateList()
        {
            InitializeComponent();
            manager = new ContextManager();
            bool allowed = Compas.Logic.Security.CurrentSecurityContext.Principal.OpperationAllowed("StaffShiftsList");

            if (allowed == true)
            {
                documentFilterUC1.Fill();
                universalFilter1.Fill();
                documentsLogic = new DocumentsLogic(manager);
                WareCategoriesLogic categoriesLogic = new WareCategoriesLogic(manager);

                BindingList<ItemIntValue> categories = categoriesLogic.GetCategoriesHierarchy();
                ViewCategoriesLUE.Properties.ValueMember = "ID";
                ViewCategoriesLUE.Properties.DisplayMember = "Name";
                ViewCategoriesLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Name", 0, "Назва категорії"));
                ViewCategoriesLUE.Properties.DataSource = categories;
                Fill();
            }
            else
            {
                MessageBox.Show("Дія заборонена. Зверніться до адміністратора.");
                this.Close();
            }
        }
Ejemplo n.º 3
0
        public DocumentsList(CashRegister _CashRegister)
        {
            InitializeComponent();
            CompasLogger.Add(String.Format("Start opening DocumentsList"), CompasLogger.Level.Info);
            cashRegister = _CashRegister;
            manager      = new ContextManager();
            bool allowed = Compas.Logic.Security.CurrentSecurityContext.Principal.OpperationAllowed("DocumentsList");

            if (allowed == true)
            {
                CompasLogger.Add(String.Format("FillDocumentFilter"), CompasLogger.Level.Info);
                documentFilterUC1.Fill();
                CompasLogger.Add(String.Format("FillUniversalFilter"), CompasLogger.Level.Info);
                universalFilter1.Fill();
                documentsLogic = new DocumentsLogic(manager);
                CompasLogger.Add(String.Format("Fill"), CompasLogger.Level.Info);
                Fill();
            }
            else
            {
                MessageBox.Show("Дія заборонена. Зверніться до адміністратора.");
                this.Close();
            }
            CompasLogger.Add(String.Format("End opening DocumentsList"), CompasLogger.Level.Info);
            //this.DataGV.CellPainting += new
            //     DataGridViewCellPaintingEventHandler(DataGV_CellPainting);
        }
Ejemplo n.º 4
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;
                }
            }
        }
Ejemplo n.º 5
0
    protected void btnMove_Click(object sender, EventArgs e)
    {
        if (!IsValid)
        {
            return;
        }

        string destinationFolderID = ddlDestination.SelectedValue;

        if (destinationFolderID == targetFolder.ID)
        {
            throw new ConciergeClientException(MemberSuite.SDK.Concierge.ConciergeErrorCode.IllegalParameter,
                                               "The source file already resides in the specified folder. Please choose another destination folder.");
        }

        if (!DocumentsLogic.CanWriteTo(LoadObjectFromAPI <msFileFolder>(destinationFolderID), ConciergeAPI.CurrentEntity.ID))
        {
            throw new ConciergeClientException(MemberSuite.SDK.Concierge.ConciergeErrorCode.IllegalParameter,
                                               "You do not have write permission for the destination folder.");
        }

        targetFile.FileFolder = destinationFolderID;
        SaveObject(targetFile);

        GoTo("BrowseFileFolder.aspx?contextID=" + targetFolder.ID, string.Format("File '{0}' has been moved successfully.", targetFile.Name));
    }
Ejemplo n.º 6
0
    protected override void InitializePage()
    {
        base.InitializePage();


        using (var api = GetServiceAPIProxy())
        {
            foldersAndFiles = api.DescribeFolder(targetFolder.ID).ResultValue;
            DocumentsLogic.SetupContextAndParentFolders(api, targetFolder, hlFolderContext, foldersAndFiles,
                                                        rptParentFolders, true);

            // get the folder path
            lblSourceFolder.Text = DocumentsLogic.GetFolderPath(api, targetFolder.ID) + @"\" + targetFile.Name;
        }



        Search sFolders = new Search(msFileFolder.CLASS_NAME);

        sFolders.AddCriteria(Expr.Equals("FileCabinet", targetFolder.FileCabinet));
        sFolders.AddOutputColumn("FolderPath");
        sFolders.AddSortColumn("FolderLevel");
        sFolders.AddSortColumn("Name");

        ddlDestination.DataSource     = APIExtensions.GetSearchResult(sFolders, 0, null).Table;
        ddlDestination.DataTextField  = "FolderPath";
        ddlDestination.DataValueField = "ID";
        ddlDestination.DataBind();

        ddlDestination.Items.Insert(0, new ListItem("--- Select a Destination Folder ---", ""));
    }
Ejemplo n.º 7
0
        public DocumentsList(CashRegister _CashRegister)
        {
            InitializeComponent();
            CompasLogger.Add(String.Format("Start opening DocumentsList"), CompasLogger.Level.Info);
            cashRegister = _CashRegister;
            manager = new ContextManager();
            bool allowed = Compas.Logic.Security.CurrentSecurityContext.Principal.OpperationAllowed("DocumentsList");

            if (allowed == true)
            {
                CompasLogger.Add(String.Format("FillDocumentFilter"), CompasLogger.Level.Info);
                documentFilterUC1.Fill();
                CompasLogger.Add(String.Format("FillUniversalFilter"), CompasLogger.Level.Info);
                universalFilter1.Fill();
                documentsLogic = new DocumentsLogic(manager);
                CompasLogger.Add(String.Format("Fill"), CompasLogger.Level.Info);
                Fill();
            }
            else
            {
                MessageBox.Show("Дія заборонена. Зверніться до адміністратора.");
                this.Close();
            }
            CompasLogger.Add(String.Format("End opening DocumentsList"), CompasLogger.Level.Info);
            //this.DataGV.CellPainting += new
            //     DataGridViewCellPaintingEventHandler(DataGV_CellPainting);
        }
Ejemplo n.º 8
0
        public DocumentsAlternateList()
        {
            InitializeComponent();
            manager = new ContextManager();
            bool allowed = Compas.Logic.Security.CurrentSecurityContext.Principal.OpperationAllowed("StaffShiftsList");



            if (allowed == true)
            {
                documentFilterUC1.Fill();
                universalFilter1.Fill();
                documentsLogic = new DocumentsLogic(manager);
                WareCategoriesLogic categoriesLogic = new WareCategoriesLogic(manager);

                BindingList <ItemIntValue> categories = categoriesLogic.GetCategoriesHierarchy();
                ViewCategoriesLUE.Properties.ValueMember   = "ID";
                ViewCategoriesLUE.Properties.DisplayMember = "Name";
                ViewCategoriesLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Name", 0, "Назва категорії"));
                ViewCategoriesLUE.Properties.DataSource = categories;
                Fill();
            }
            else
            {
                MessageBox.Show("Дія заборонена. Зверніться до адміністратора.");
                this.Close();
            }
        }
Ejemplo n.º 9
0
    protected override bool CheckSecurity()
    {
        if (!base.CheckSecurity())
        {
            return(false);
        }

        return(DocumentsLogic.CanAccess(targetFolder.FileCabinet, targetFolder.ID, ConciergeAPI.CurrentEntity.ID));
    }
Ejemplo n.º 10
0
    protected override bool CheckSecurity()
    {
        if (!base.CheckSecurity())
        {
            return(false);
        }

        return(DocumentsLogic.CanWriteTo(targetFolder, ConciergeAPI.CurrentEntity.ID));
    }
    protected override bool CheckSecurity()
    {
        if (!base.CheckSecurity())
        {
            return(true);
        }

        using (var api = GetConciegeAPIProxy())
            return(DocumentsLogic.CanViewMembershipDocuments(api, ContextID, ConciergeAPI.CurrentEntity.ID));
    }
Ejemplo n.º 12
0
    protected override void InitializePage()
    {
        base.InitializePage();


        using (var api = GetServiceAPIProxy())
        {
            foldersAndFiles = api.DescribeFolder(targetFolder.ID).ResultValue;
            DocumentsLogic.SetupContextAndParentFolders(api, targetFolder, hlFolderContext, foldersAndFiles,
                                                        rptParentFolders, true);
        }
    }
Ejemplo n.º 13
0
        private void EditSB_Click(object sender, EventArgs e)
        {
            DocumentData form = new DocumentData("edit", Convert.ToInt32(DataGV.SelectedRows[0].Cells["ID"].Value), null);

            form.ShowDialog();
            manager.Save();
            manager.CloseContext();
            manager        = new ContextManager();
            documentsLogic = new DocumentsLogic(manager);

            Fill();
        }
Ejemplo n.º 14
0
    protected override void InitializePage()
    {
        base.InitializePage();
        establishWhetherUserHasUploadAccess();

        bindFilesAndFolders();
        using (var api = GetServiceAPIProxy())
            DocumentsLogic.SetupContextAndParentFolders(api, targetFolder, hlFolderContext, foldersAndFiles, rptParentFolders, false);

        lblFolderName.Text = targetFolder.Name;

        setupLinks();
        setupContextButton();
    }
Ejemplo n.º 15
0
    protected void btnBack_Click(object sender, EventArgs e)
    {
        MemberSuiteObject mso;

        using (var api = GetServiceAPIProxy())
            mso = DocumentsLogic.GetFileCabinetContext(api, targetFolder);

        if (mso == null)
        {
            GoTo("/documents/DigitalLibrary.aspx");
        }

        GoTo(NavigationLogic.GetUrlFor(mso));
    }
Ejemplo n.º 16
0
        private void DataGV_DoubleClick(object sender, EventArgs e)
        {
            if (DataGV.SelectedRows.Count > 0)
            {
                DocumentData form = new DocumentData("edit", Convert.ToInt32(DataGV.SelectedRows[0].Cells["ID"].Value), null);
                form.ShowDialog();
                manager.Save();
                manager.CloseContext();
                manager = new ContextManager();
                documentsLogic = new DocumentsLogic(manager);

                Fill();
            }
        }
Ejemplo n.º 17
0
    private void setupContextButton()
    {
        MemberSuiteObject mso;

        using (var api = GetConciegeAPIProxy())
            mso = DocumentsLogic.GetFileCabinetContext(api, targetFolder);

        if (mso == null)
        {
            btnBack.Text = "Back to My Digital Library";
        }
        else
        {
            btnBack.Text = "Back to " + mso["Name"];
        }
    }
Ejemplo n.º 18
0
    protected void rptFolders_OnItemCommand(object source, RepeaterCommandEventArgs e)
    {
        var          folderId = e.CommandArgument.ToString();
        msFileFolder f        = LoadObjectFromAPI <msFileFolder>(folderId);

        if (!DocumentsLogic.CanWriteTo(f, ConciergeAPI.CurrentEntity.ID))
        {
            throw new ConciergeClientException(ConciergeErrorCode.AccessDenied, "You do not have access the delete the specified folder.");
        }

        using (var api = GetServiceAPIProxy())
            api.DeleteFolderTree(folderId);


        QueueBannerMessage("The folder (and all subfolders and files) have been successfully deleted.");
        Refresh();
    }
Ejemplo n.º 19
0
        public void Recalculate(DateTime StartDate)
        {
            DocumentsLogic            documents    = new DocumentsLogic(manager);
            DocumentDetailsLogic      detailsLogic = new DocumentDetailsLogic(manager);
            List <WareDocumentDetail> details      = detailsLogic.GetAll(StartDate);

            foreach (WareDocumentDetail detail in details)
            {
                if (detail.WareDocument.FromStructureObjectID != null)
                {
                    this.UpdateCurrentRemainByDocumentDetail(StartDate, detail.WareID, detail.WareDocument.FromStructureObjectID, null);
                }
                if (detail.WareDocument.ToStructureObjectD != null)
                {
                    this.UpdateCurrentRemainByDocumentDetail(StartDate, detail.WareID, detail.WareDocument.ToStructureObjectD, null);
                }
            }
        }
Ejemplo n.º 20
0
    protected override void InitializePage()
    {
        base.InitializePage();


        using (var api = GetServiceAPIProxy())
        {
            foldersAndFiles = api.DescribeFolder(targetFolder.ID).ResultValue;
            DocumentsLogic.SetupContextAndParentFolders(api, targetFolder, hlFolderContext, foldersAndFiles,
                                                        rptParentFolders, true);
        }

        tbName.Text        = targetFile.Name;
        tbDescription.Text = targetFile.Description;

        if (targetFolder.Type == FileFolderType.Public)
        {
            lPublicLink.Text = GetImageUrl(targetFile.ID);
        }
    }
Ejemplo n.º 21
0
    protected override void InitializePage()
    {
        base.InitializePage();


        using (var api = GetServiceAPIProxy())
        {
            foldersAndFiles = api.DescribeFolder(targetFolder.ID).ResultValue;
            DocumentsLogic.SetupContextAndParentFolders(api, targetFolder, hlFolderContext, foldersAndFiles,
                                                        rptParentFolders, true);
        }

        if (isEdit)
        {
            rblType.SelectedValue = targetFolder.Type.ToString();
            tbName.Text           = targetFolder.Name;
            tbDescription.Text    = targetFolder.Description;
            cbAdmin.Checked       = targetFolder.OnlyLeadersCanUploadFiles;
        }

        cbAdmin.Visible = DocumentsLogic.HasAdministrativeAccessTo(targetFolder, ConciergeAPI.CurrentEntity.ID);
    }
Ejemplo n.º 22
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);
        }
Ejemplo n.º 23
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);
        }
Ejemplo n.º 24
0
 private void establishWhetherUserHasUploadAccess()
 {
     hasWriteAccess = DocumentsLogic.CanWriteTo(targetFolder, ConciergeAPI.CurrentEntity.ID);
 }
Ejemplo n.º 25
0
        private void Fill()
        {
            documentsLogic = new DocumentsLogic(manager);
            int? selectedIndex = null;
            if (DataGV.SelectedRows.Count > 0)
            {
                selectedIndex = DataGV.SelectedRows[0].Index;
            }

            int? documentTypeId = null;
            string documentNumber = "";
            DateTime startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
            DateTime? endDate = null;
            decimal? documentSum = null;

            if(documentFilterUC1.DocumentTypeID >= 0)
                documentTypeId = documentFilterUC1.DocumentTypeID;
            documentNumber = documentFilterUC1.DocumentNumber;
            startDate = universalFilter1.StartDate == null ? startDate : Convert.ToDateTime(universalFilter1.StartDate);
            endDate = universalFilter1.EndDate;
            documentSum = documentFilterUC1.DocumentSum;
            int? wareId = universalFilter1.WareID;
            int? categoryId = universalFilter1.WareCategoryID;
            int? stateId = universalFilter1.StateID;

            SortableBindingList<DocumentView> view =
                    new SortableBindingList<DocumentView>(documentsLogic.GetAllView(documentTypeId, documentNumber,
                        startDate, endDate, documentSum, wareId, categoryId, stateId));

            DataGV.AutoGenerateColumns = false;
            DataGV.DataSource = view;
            DataGV.Update();

            decimal summaryDocSum = 0;
            decimal summaryPayments = 0;
            foreach (DocumentView v in view)
            {
                summaryDocSum = summaryDocSum + v.DocumentSum;
                summaryPayments = summaryPayments + v.PaySum;
            }

            SummaryL.Text = "Сума под документам: " + summaryDocSum.ToString("n2") + "     Сума оплат: " + summaryPayments.ToString("n2");

            if (selectedIndex != null)
                if (DataGV.RowCount > selectedIndex)
                    DataGV.Rows[Convert.ToInt32(selectedIndex)].Selected = true;

            foreach (DataGridViewRow r in DataGV.Rows)
            {
                if (r.Cells["DocumentSum"].Value.ToString() != r.Cells["PaySum"].Value.ToString())
                {
                    r.DefaultCellStyle.BackColor = Color.Yellow;
                    //foreach (DataGridViewCell c in r.Cells)
                    //{
                    //c.d
                    //}
                }

            }
        }
Ejemplo n.º 26
0
        private void EditSB_Click(object sender, EventArgs e)
        {
            DocumentData form = new DocumentData("edit", Convert.ToInt32(DataGV.SelectedRows[0].Cells["ID"].Value), cashRegister);
            form.ShowDialog();
            manager.Save();
            manager.CloseContext();
            manager = new ContextManager();
            documentsLogic = new DocumentsLogic(manager);

            Fill();
        }
Ejemplo n.º 27
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();
                }
            }
        }
Ejemplo n.º 28
0
        private void Fill()
        {
            documentsLogic = new DocumentsLogic(manager);
            int?selectedIndex = null;

            if (DataGV.SelectedRows.Count > 0)
            {
                selectedIndex = DataGV.SelectedRows[0].Index;
            }

            int?     documentTypeId = null;
            string   documentNumber = "";
            DateTime startDate      = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
            DateTime?endDate        = null;
            decimal? documentSum    = null;

            if (documentFilterUC1.DocumentTypeID >= 0)
            {
                documentTypeId = documentFilterUC1.DocumentTypeID;
            }
            documentNumber = documentFilterUC1.DocumentNumber;
            startDate      = universalFilter1.StartDate == null ? startDate : Convert.ToDateTime(universalFilter1.StartDate);
            endDate        = universalFilter1.EndDate;
            documentSum    = documentFilterUC1.DocumentSum;
            int?wareId     = universalFilter1.WareID;
            int?categoryId = universalFilter1.WareCategoryID;
            int?stateId    = universalFilter1.StateID;

            SortableBindingList <DocumentView> view =
                new SortableBindingList <DocumentView>(documentsLogic.GetAllView(documentTypeId, documentNumber,
                                                                                 startDate, endDate, documentSum, wareId, categoryId, stateId));

            DataGV.AutoGenerateColumns = false;
            DataGV.DataSource          = view;
            DataGV.Update();

            decimal summaryDocSum   = 0;
            decimal summaryPayments = 0;

            foreach (DocumentView v in view)
            {
                summaryDocSum   = summaryDocSum + v.DocumentSum;
                summaryPayments = summaryPayments + v.PaySum;
            }

            SummaryL.Text = "Сума под документам: " + summaryDocSum.ToString("n2") + "     Сума оплат: " + summaryPayments.ToString("n2");

            if (selectedIndex != null)
            {
                if (DataGV.RowCount > selectedIndex)
                {
                    DataGV.Rows[Convert.ToInt32(selectedIndex)].Selected = true;
                }
            }

            foreach (DataGridViewRow r in DataGV.Rows)
            {
                if (r.Cells["DocumentSum"].Value.ToString() != r.Cells["PaySum"].Value.ToString())
                {
                    r.DefaultCellStyle.BackColor = Color.Yellow;
                    //foreach (DataGridViewCell c in r.Cells)
                    //{
                    //c.d
                    //}
                }
            }
        }
Ejemplo n.º 29
0
 protected override bool CheckSecurity()
 {
     return(DocumentsLogic.CheckTemporaryFileAccess(ContextID) || DocumentsLogic.CanAccessFile(ContextID));
 }
Ejemplo n.º 30
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();
                }
            }
        }
Ejemplo n.º 31
0
        public int Recalculate(DateTime Month, int StructureObjectID)
        {
            int result = 1;
            StaffEmployeeLogic         employeesLogic        = new StaffEmployeeLogic(manager);
            StaffStructureObjectsLogic structureObjectsLogic = new StaffStructureObjectsLogic(manager);
            //List<Helpers.ItemIntValue> structureObjects = structureObjectsLogic.GetStructureObjectsHierarchy(false, StructureObjectID).ToList();
            //спочатку вибираємо працівників, що працюють в цьому відділі і всіх дочірніх відділах
            StaffEmployeePositionsLogic positionsLogic = new StaffEmployeePositionsLogic(manager);


            List <StaffEmployee> employees = positionsLogic.GetAllWithSubDepartments(StructureObjectID);;

            //проходимо покожному окремому працівнику
            foreach (StaffEmployee employee in employees)
            {
                //здійснюємо перерахунок по цьому працівнику

                decimal prevMonthSalary          = 0;
                decimal prevMonthExtraPercent    = 0;
                decimal currentMonthSalary       = 0;
                decimal currentMonthExtraPercent = 0;
                decimal documentsSum             = 0;

                //шукаємо документи до яких прикріплений даний працівник
                DocumentsLogic            documentsLogic            = new DocumentsLogic(manager);
                DocumentDetailsLogic      documentDetailsLogic      = new DocumentDetailsLogic(manager);
                DocumentStaffDetailsLogic documentStaffDetailsLogic = new DocumentStaffDetailsLogic(manager);
                List <WareDocument>       documents = documentsLogic.GetDocumentsByEmployeeID(employee.ID, Month, Month.AddMonths(1));

                //визначаємо суму документів
                foreach (WareDocument document in documents)
                {
                    documentsSum = documentsSum + document.DocumentSum;
                }


                //для цього спочатку шукаємо оклад працівника за ПОТОЧНИЙ місяць, якщо такий відсутній, то прирівнюємо до 0
                StaffEmployeeSalary currentSalary = this.GetByEmployeeID(employee.ID, Month);
                if (currentSalary != null)
                {
                    currentMonthSalary       = currentSalary.Salary;
                    currentMonthExtraPercent = currentSalary.ExtraPercent;
                    currentSalary.SumSale    = documentsSum;
                    currentSalary.SumSalary  = currentSalary.SumSale * (currentMonthExtraPercent / 100) + currentMonthSalary;
                }
                else
                {
                    //для цього спочатку шукаємо оклад працівника за попередній місяць, якщо такий відсутній, то прирівнюємо до 0
                    StaffEmployeeSalary prevSalary = this.GetByEmployeeID(employee.ID, Month.AddMonths(-1));
                    if (prevSalary != null)
                    {
                        prevMonthSalary       = prevSalary.Salary;
                        prevMonthExtraPercent = prevSalary.ExtraPercent;
                    }
                    currentMonthSalary       = prevMonthSalary;
                    currentMonthExtraPercent = prevMonthExtraPercent;
                    this.Create(Month, StructureObjectID, employee.ID, documentsSum, currentMonthExtraPercent, currentMonthSalary);
                }
            }

            return(result);
        }