Пример #1
0
        private void FillTimeLimits()
        {
            WareTimeLimitsLogic timeLimits = new WareTimeLimitsLogic(manager);
            WareTimeLimit       lastLimit  = timeLimits.GetByWareID(Convert.ToInt32(id));

            if (lastLimit != null)
            {
                TimeLimitNUD.Value = lastLimit.TimeLimit;
            }
        }
Пример #2
0
        /// <summary>
        /// Заповнюємо перелік позицій документу
        /// </summary>
        private void FillDetails()
        {
            CompasLogger.Add(String.Format("FillDetails1"), CompasLogger.Level.Info);
            int? selectedIndex = null;
            if (DetailsGV.SelectedRows.Count > 0)
            {
                selectedIndex = DetailsGV.SelectedRows[0].Index;
            }

            DocumentDetailsLogic detailsLogic = new DocumentDetailsLogic(manager);

            //documentDetailsView = documentDetailsNew;
            if (mode == "edit")
            {
                if (documentDetailsView.Count == 0)
                {
                    documentDetailsView = detailsLogic.GetAll(id);
                }

            }
            if ((mode == "new") & (documentDetailsView == null))
                documentDetailsView = new List<WareDocumentDetail>();

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

            CompasLogger.Add(String.Format("FillDetails2"), CompasLogger.Level.Info);
            //foreach (WareDocumentDetail a in documentDetailsNew)
            //{
            //    documentDetailsView.Add(a);
            //}
            //documentDetailsNew.Clear();

            //конвертуємо в список для перегляду і підраховуємо загальну суму документу
            //if (documentDetailsViewer == null)
            documentDetailsViewer = new List<DocumentDetailView>();
            documentSum = 0;
            decimal documentDuration = 0;
            WareTimeLimitsLogic timeLimitsLogic = new WareTimeLimitsLogic(manager);
            if (documentDetailsView.Count > 0)
            {
                foreach (WareDocumentDetail detail in documentDetailsView.OrderBy(a => a.ID))
                {
                    //if(documentDetailsViewer.Contains(
                    DocumentDetailView detailView = new DocumentDetailView(detail, manager);

                    documentDetailsViewer.Add(detailView);
                    documentSum = documentSum + Convert.ToDecimal(detail.EndPrice);

                    WareTimeLimit timeLimit = timeLimitsLogic.GetByWareID(detail.WareID);
                    if (timeLimit != null)
                    {
                        documentDuration = documentDuration + timeLimit.TimeLimit;
                    }

                }
            }

            CompasLogger.Add(String.Format("FillDetails3"), CompasLogger.Level.Info);
            DurationL.Text = documentDuration.ToString("n2");
            DocumentSumaL.Text = documentSum.ToString("n2");
            DetailsGV.AutoGenerateColumns = false;
            DetailsGV.DataSource = documentDetailsViewer;
            if (DetailsGV.Rows.Count == 0)
            {
                if(DetailsGV.SelectedRows.Count >0)
                    DetailsGV.SelectedRows[0].Selected = false;
            }
            //DetailsGV.Update();
            CompasLogger.Add(String.Format("FillDetails4"), CompasLogger.Level.Info);
        }
Пример #3
0
        /// <summary>
        /// Заповнюємо перелік позицій документу
        /// </summary>
        private void FillDetails()
        {
            CompasLogger.Add(String.Format("FillDetails1"), CompasLogger.Level.Info);
            int?selectedIndex = null;

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

            DocumentDetailsLogic detailsLogic = new DocumentDetailsLogic(manager);

            //documentDetailsView = documentDetailsNew;
            if (mode == "edit")
            {
                if (documentDetailsView.Count == 0)
                {
                    documentDetailsView = detailsLogic.GetAll(id);
                }
            }
            if ((mode == "new") & (documentDetailsView == null))
            {
                documentDetailsView = new List <WareDocumentDetail>();
            }

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

            CompasLogger.Add(String.Format("FillDetails2"), CompasLogger.Level.Info);
            //foreach (WareDocumentDetail a in documentDetailsNew)
            //{
            //    documentDetailsView.Add(a);
            //}
            //documentDetailsNew.Clear();

            //конвертуємо в список для перегляду і підраховуємо загальну суму документу
            //if (documentDetailsViewer == null)
            documentDetailsViewer = new List <DocumentDetailView>();
            documentSum           = 0;
            decimal             documentDuration = 0;
            WareTimeLimitsLogic timeLimitsLogic  = new WareTimeLimitsLogic(manager);

            if (documentDetailsView.Count > 0)
            {
                foreach (WareDocumentDetail detail in documentDetailsView.OrderBy(a => a.ID))
                {
                    //if(documentDetailsViewer.Contains(
                    DocumentDetailView detailView = new DocumentDetailView(detail, manager);

                    documentDetailsViewer.Add(detailView);
                    documentSum = documentSum + Convert.ToDecimal(detail.EndPrice);

                    WareTimeLimit timeLimit = timeLimitsLogic.GetByWareID(detail.WareID);
                    if (timeLimit != null)
                    {
                        documentDuration = documentDuration + timeLimit.TimeLimit;
                    }
                }
            }

            CompasLogger.Add(String.Format("FillDetails3"), CompasLogger.Level.Info);
            DurationL.Text                = documentDuration.ToString("n2");
            DocumentSumaL.Text            = documentSum.ToString("n2");
            DetailsGV.AutoGenerateColumns = false;
            DetailsGV.DataSource          = documentDetailsViewer;
            if (DetailsGV.Rows.Count == 0)
            {
                if (DetailsGV.SelectedRows.Count > 0)
                {
                    DetailsGV.SelectedRows[0].Selected = false;
                }
            }
            //DetailsGV.Update();
            CompasLogger.Add(String.Format("FillDetails4"), CompasLogger.Level.Info);
        }
Пример #4
0
        private void SaveBt_Click(object sender, EventArgs e)
        {
            WaresLogic     wares      = new WaresLogic(manager);
            WareCodesLogic codes      = new WareCodesLogic(manager);
            string         name       = NameTB.Text;
            int?           categoryId = null;

            if (CategoriesCB.SelectedIndex > 0)
            {
                categoryId = Convert.ToInt32(CategoriesCB.SelectedValue);
            }
            int?manufacturerId = null;

            if (ManufacturersCB.SelectedIndex > 0)
            {
                manufacturerId = Convert.ToInt32(ManufacturersCB.SelectedValue);
            }
            int     unitId                = Convert.ToInt32(UnitsCB.SelectedValue);
            int?    secondaryUnitId       = null;
            decimal?secondaryUnitQuantity = null;
            decimal timeLimit             = 0;

            timeLimit = TimeLimitNUD.Value;

            if (SecondaryUnitsCB.SelectedIndex > 0)
            {
                secondaryUnitId       = Convert.ToInt32(SecondaryUnitsCB.SelectedValue);
                secondaryUnitQuantity = Convert.ToDecimal(SecondaryQuantityNUD.Value);
            }
            Model.Ware ware = null;

            //зберігаємо код якщо він введений в текстове поле, а інших кодів немає
            if ((codesList.Count == 0) & (CodeTB.Text.Trim().Length > 0))
            {
                codesList.Add(CodeTB.Text.Trim());
                codesListForDelete.Remove(CodeTB.Text.Trim());
            }

            if (mode == "new")
            {
                if (openFileDialog1.CheckPathExists == true)
                {
                    image = Helpers.ImageOperations.ConvertImageToByteArray(openFileDialog1.FileName);
                }
                ware = wares.Create(NameTB.Text, unitId, 0, manufacturerId, categoryId, secondaryUnitId, secondaryUnitQuantity, image);
            }
            if (mode == "edit")
            {
                if (_image != null)
                {
                    image = Helpers.ImageOperations.ImageToByteArray(_image);
                }
                else
                {
                    image = null;
                }
                ware = wares.Update(Convert.ToInt32(id), NameTB.Text, unitId, manufacturerId, categoryId, secondaryUnitId, secondaryUnitQuantity, image);
                foreach (string code in codesListForDelete)
                {
                    codes.Delete(Convert.ToInt32(id), code);
                }
            }



            foreach (string code in codesList)
            {
                if (codes.CodeForOtherWareExists(id, code) == false)
                {
                    codes.Create(ware, code);
                }
                else
                {
                    MessageBox.Show("Введений код " + code + " вже існує і не був збережений");
                }
            }


            WareTimeLimitsLogic timeLimits = new WareTimeLimitsLogic(manager);

            timeLimits.Create(ware, Convert.ToDecimal(TimeLimitNUD.Value), true);



            manager.Save();

            if (AddComponentsCB.Checked == true)
            {
                Wares.Ware.WareComponentData form = new Wares.Ware.WareComponentData("edit", Convert.ToInt32(ware.ID));

                form.ShowDialog();
            }
            this.Close();
        }
Пример #5
0
        private void SaveBt_Click(object sender, EventArgs e)
        {
            WaresLogic wares = new WaresLogic(manager);
            WareCodesLogic codes = new WareCodesLogic(manager);
            string name = NameTB.Text;
            int? categoryId = null;
            if (CategoriesCB.SelectedIndex > 0)
                categoryId = Convert.ToInt32(CategoriesCB.SelectedValue);
            int? manufacturerId = null;
            if (ManufacturersCB.SelectedIndex > 0)
                manufacturerId = Convert.ToInt32(ManufacturersCB.SelectedValue);
            int unitId = Convert.ToInt32(UnitsCB.SelectedValue);
            int? secondaryUnitId = null;
            decimal? secondaryUnitQuantity = null;
            decimal timeLimit = 0;

            timeLimit = TimeLimitNUD.Value;

            if (SecondaryUnitsCB.SelectedIndex > 0)
            {
                secondaryUnitId = Convert.ToInt32(SecondaryUnitsCB.SelectedValue);
                secondaryUnitQuantity = Convert.ToDecimal(SecondaryQuantityNUD.Value);
            }
            Model.Ware ware = null;

            //зберігаємо код якщо він введений в текстове поле, а інших кодів немає
            if ((codesList.Count == 0) & (CodeTB.Text.Trim().Length > 0))
            {
                codesList.Add(CodeTB.Text.Trim());
                codesListForDelete.Remove(CodeTB.Text.Trim());
            }

            if (mode == "new")
            {
                if (openFileDialog1.CheckPathExists == true)
                    image = Helpers.ImageOperations.ConvertImageToByteArray(openFileDialog1.FileName);
                ware = wares.Create(NameTB.Text, unitId, 0, manufacturerId, categoryId, secondaryUnitId, secondaryUnitQuantity,image);
            }
            if (mode == "edit")
            {
                if (_image != null)
                    image = Helpers.ImageOperations.ImageToByteArray(_image);
                else
                    image = null;
                ware = wares.Update(Convert.ToInt32(id), NameTB.Text, unitId, manufacturerId, categoryId, secondaryUnitId, secondaryUnitQuantity, image);
                foreach (string code in codesListForDelete)
                {
                    codes.Delete(Convert.ToInt32(id), code);
                }
            }

            foreach (string code in codesList)
            {
                if (codes.CodeForOtherWareExists(id, code) == false)
                    codes.Create(ware, code);
                else
                    MessageBox.Show("Введений код " + code + " вже існує і не був збережений");

            }

            WareTimeLimitsLogic timeLimits = new WareTimeLimitsLogic(manager);
            timeLimits.Create(ware, Convert.ToDecimal(TimeLimitNUD.Value), true);

            manager.Save();

            if (AddComponentsCB.Checked == true)
            {
                Wares.Ware.WareComponentData form = new Wares.Ware.WareComponentData("edit", Convert.ToInt32(ware.ID));

                form.ShowDialog();
            }
            this.Close();
        }
Пример #6
0
 private void FillTimeLimits()
 {
     WareTimeLimitsLogic timeLimits = new WareTimeLimitsLogic(manager);
     WareTimeLimit lastLimit = timeLimits.GetByWareID(Convert.ToInt32(id));
     if (lastLimit != null)
     {
         TimeLimitNUD.Value = lastLimit.TimeLimit;
     }
 }