Ejemplo n.º 1
0
        private async void Btn_update_Click(object sender, RoutedEventArgs e)
        {//update
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }
                if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "update") || SectionData.isAdminPermision())
                {
                    if (unit.unitId > 0)
                    {
                        //validate values
                        validateEmptyValues();

                        if (!tb_name.Text.Equals(""))
                        {
                            // check if new unit doesn't match old units
                            var unitObj = units.ToList().Find(x => x.name == tb_name.Text);
                            if (unitObj is null || unitObj.name == unit.name)
                            {
                                unit.name  = tb_name.Text;
                                unit.notes = tb_notes.Text;

                                int res = await unitModel.save(unit);

                                if (res > 0)
                                {
                                    Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopUpdate"), animation: ToasterAnimation.FadeIn);
                                }
                                else
                                {
                                    Toaster.ShowError(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                                }

                                await RefreshUnitsList();

                                Tb_search_TextChanged(null, null);
                            }
                            else
                            {
                                Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trErrorDuplicateUnitNameToolTip"), animation: ToasterAnimation.FadeIn);
                            }
                        }
                    }
                    else
                    {
                        Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trSelectItemFirst"), animation: ToasterAnimation.FadeIn);
                    }
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }

                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
Ejemplo n.º 2
0
        private async void Btn_refresh_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "show") || SectionData.isAdminPermision())
                {
                    await RefreshSectionsList();

                    Tb_search_TextChanged(null, null);
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
        private void Btn_pieChart_Click(object sender, RoutedEventArgs e)
        {//pie
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "report") || SectionData.isAdminPermision())
                {
                    Window.GetWindow(this).Opacity = 0.2;
                    win_lvcCatalog win = new win_lvcCatalog(storageCostQuery, 4);
                    win.ShowDialog();
                    Window.GetWindow(this).Opacity = 1;
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 4
0
        private void Btn_addRange_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (MainWindow.groupObject.HasPermissionAction(addRangePermission, MainWindow.groupObjects, "one") || SectionData.isAdminPermision())
                {
                    Window.GetWindow(this).Opacity = 0.2;
                    wd_locationAddRange w = new wd_locationAddRange();
                    w.ShowDialog();
                    Window.GetWindow(this).Opacity = 1;
                    Btn_refresh_Click(null, null);
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 5
0
        private void Btn_pieChart_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }


                if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "report") || SectionData.isAdminPermision())
                {
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 6
0
        private async void Btn_update_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }
                //update
                if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "update") || SectionData.isAdminPermision())
                {
                    if (section.sectionId > 0)
                    {
                        if (validate(section))
                        {
                            section.name = tb_name.Text;
                            //section.branchId = Convert.ToInt32(cb_branch.SelectedValue);
                            section.note         = tb_note.Text;
                            section.updateUserId = MainWindow.userID;

                            int s = await sectionModel.save(section);

                            if (s > 0)
                            {
                                Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopUpdate"), animation: ToasterAnimation.FadeIn);
                            }
                            else
                            {
                                Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                            }

                            await RefreshSectionsList();

                            Tb_search_TextChanged(null, null);
                        }
                    }
                    else
                    {
                        Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trSelectItemFirst"), animation: ToasterAnimation.FadeIn);
                    }
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 7
0
        private void Btn_print_Click(object sender, RoutedEventArgs e)
        {//print
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (MainWindow.groupObject.HasPermissionAction(reportsPermission, MainWindow.groupObjects, "one") || SectionData.isAdminPermision())
                {
                    #region
                    if (invItemsQuery != null)
                    {
                        List <ReportParameter> paramarr = new List <ReportParameter>();

                        string addpath;
                        bool   isArabic = ReportCls.checkLang();
                        if (isArabic)
                        {
                            addpath = @"\Reports\Store\Ar\ArDestroyReport.rdlc";
                        }
                        else
                        {
                            addpath = @"\Reports\Store\EN\DestroyReport.rdlc";
                        }
                        string reppath = reportclass.PathUp(Directory.GetCurrentDirectory(), 2, addpath);

                        ReportCls.checkLang();

                        clsReports.invItem(invItemsQuery, rep, reppath, paramarr);
                        clsReports.setReportLanguage(paramarr);
                        clsReports.Header(paramarr);

                        rep.SetParameters(paramarr);
                        rep.Refresh();
                        LocalReportExtensions.PrintToPrinterbyNameAndCopy(rep, MainWindow.rep_printer_name, short.Parse(MainWindow.rep_print_count));
                    }
                    #endregion
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 8
0
        //************************************************
        //******************* update property***************
        private async void Btn_update_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }
                if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "update") || SectionData.isAdminPermision())
                {
                    //update
                    if (property.propertyId > 0)
                    {
                        property.name         = tb_name.Text;
                        property.createUserId = MainWindow.userID;
                        property.updateUserId = MainWindow.userID;

                        int res = await propertyModel.save(property);

                        if (res > 0)
                        {
                            Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopUpdate"), animation: ToasterAnimation.FadeIn);
                        }
                        else
                        {
                            Toaster.ShowError(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                        }

                        await RefreshPropertiesList();

                        Tb_search_TextChanged(null, null);
                        //var poss = await propertyModel.getProperty();
                        //dg_property.ItemsSource = poss;
                    }
                    else
                    {
                        Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trSelectItemFirst"), animation: ToasterAnimation.FadeIn);
                    }
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 9
0
 private void Btn_exportToExcel_Click(object sender, RoutedEventArgs e)
 {
     if (MainWindow.groupObject.HasPermissionAction(reportsPermission, MainWindow.groupObjects, "one") || SectionData.isAdminPermision())
     {
     }
     else
     {
         Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
     }
 }
Ejemplo n.º 10
0
        private void Btn_preview_Click(object sender, RoutedEventArgs e)
        {//preview
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (MainWindow.groupObject.HasPermissionAction(reportsPermission, MainWindow.groupObjects, "one") || SectionData.isAdminPermision())
                {
                    #region
                    if (itemLocationListQuery != null)
                    {
                        Window.GetWindow(this).Opacity = 0.2;

                        string pdfpath = "";



                        pdfpath = @"\Thumb\report\temp.pdf";
                        pdfpath = reportclass.PathUp(Directory.GetCurrentDirectory(), 2, pdfpath);

                        BuildReport();

                        LocalReportExtensions.ExportToPDF(rep, pdfpath);
                        wd_previewPdf w = new wd_previewPdf();
                        w.pdfPath = pdfpath;
                        if (!string.IsNullOrEmpty(w.pdfPath))
                        {
                            w.ShowDialog();
                            w.wb_pdfWebViewer.Dispose();
                        }
                        Window.GetWindow(this).Opacity = 1;
                    }
                    #endregion
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 11
0
        private async Task fillItemLocations()
        {
            int sequence = 0;

            _DestroyAmount  = 0;
            _ShortageAmount = 0;
            invItemsLocations.Clear();
            inventory = new Inventory();
            inventory = await inventory.getByBranch("d", MainWindow.branchID.Value);

            if (inventory.inventoryId == 0)// there is no draft in branch
            {
                itemsLocations = await itemLocationModel.getAll(MainWindow.branchID.Value);

                foreach (ItemLocation il in itemsLocations)
                {
                    sequence++;
                    InventoryItemLocation iil = new InventoryItemLocation();
                    iil.sequence        = sequence;
                    iil.itemName        = il.itemName;
                    iil.section         = il.section;
                    iil.location        = il.location;
                    iil.unitName        = il.unitName;
                    iil.quantity        = (int)il.quantity;
                    iil.itemLocationId  = il.itemsLocId;
                    iil.isDestroyed     = false;
                    iil.isFalls         = false;
                    iil.amountDestroyed = 0;
                    iil.amount          = 0;
                    iil.createUserId    = MainWindow.userLogin.userId;

                    invItemsLocations.Add(iil);

                    //calculate _ShortageCount
                    _ShortageAmount += (int)il.quantity;
                }
                tb_shortage.Text = _ShortageAmount.ToString();
                await inputEditable();

                dg_items.ItemsSource = invItemsLocations.ToList();
                if (firstTimeForDatagrid)
                {
                    await Task.Delay(1000);

                    dg_items.Items.Refresh();
                    firstTimeForDatagrid = false;
                }
            }
            else
            {
                Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trDraftExist"), animation: ToasterAnimation.FadeIn);
            }
        }
Ejemplo n.º 12
0
        private async void Btn_archive_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (MainWindow.groupObject.HasPermissionAction(archivingPermission, MainWindow.groupObjects, "one") || MainWindow.groupObject.HasPermissionAction(createInventoryPermission, MainWindow.groupObjects, "one"))
                {
                    if (invItemsLocations.Count > 0)
                    {
                        if (_InventoryType == "n")
                        {
                            await addInventory("a"); // a:archived
                        }
                        else if (_InventoryType == "d")
                        {
                            var inv = await inventory.getByBranch("n", MainWindow.branchID.Value);

                            if (inv.inventoryId == 0)
                            {
                                await addInventory("n"); // n:normal
                            }
                            else
                            {
                                Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trWarningOneInventory"), animation: ToasterAnimation.FadeIn);
                            }
                        }
                    }
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 13
0
        private void Btn_exportToExcel_Click(object sender, RoutedEventArgs e)
        {//excel
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (MainWindow.groupObject.HasPermissionAction(reportsPermission, MainWindow.groupObjects, "one") || SectionData.isAdminPermision())
                {
                    #region
                    if (itemLocationListQuery != null)
                    {
                        //Thread t1 = new Thread(() =>
                        //{
                        BuildReport();
                        this.Dispatcher.Invoke(() =>
                        {
                            saveFileDialog.Filter = "EXCEL|*.xls;";
                            if (saveFileDialog.ShowDialog() == true)
                            {
                                string filepath = saveFileDialog.FileName;
                                LocalReportExtensions.ExportToExcel(rep, filepath);
                            }
                        });

                        //});
                        //t1.Start();
                    }
                    #endregion
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 14
0
        private async void Btn_Inventory_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (_InventoryType.Equals("d") && invItemsLocations.Count > 0)
                {
                    await addInventory("d"); // d:draft
                }
                inventory = await inventory.getByBranch("n", MainWindow.branchID.Value);

                if (inventory.inventoryId == 0)
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trNoInventory"), animation: ToasterAnimation.FadeIn);
                }
                else
                {
                    if (_InventoryType == "n" && invItemsLocations.Count > 0)
                    {
                    }
                    else
                    {
                        txt_titleDataGrid.Text = MainWindow.resourcemanager.GetString("trStocktaking");
                        _InventoryType         = "n";
                        await refreshDocCount(inventory.inventoryId);
                        await fillInventoryDetails();
                    }
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 15
0
 private void Btn_subscriptionFees_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (MainWindow.groupObject.HasPermissionAction(subscriptionFeesPermission, MainWindow.groupObjects, "one") || SectionData.isAdminPermision())
         {
         }
         else
         {
             Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
         }
     }
     catch (Exception ex)
     {
         SectionData.ExceptionMessage(ex, this);
     }
 }
Ejemplo n.º 16
0
        private async void Btn_locations_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }
                //locations
                if (MainWindow.groupObject.HasPermissionAction(selectLocationPermission, MainWindow.groupObjects, "one") || SectionData.isAdminPermision())
                {
                    SectionData.clearValidate(tb_name, p_errorName);
                    //location = await locationModel.getLocsBySectionId(section.sectionId);
                    Window.GetWindow(this).Opacity = 0.2;
                    wd_locationsList w = new wd_locationsList();
                    //Pre Locations
                    //w.selectedLocations = await locationModel.getLocsBySectionId(section.sectionId);
                    w.sectionId = section.sectionId;
                    w.ShowDialog();
                    if (w.isActive)
                    {
                        await locationModel.saveLocationsSection(w.selectedLocations, section.sectionId, MainWindow.userLogin.userId);
                    }
                    Window.GetWindow(this).Opacity = 1;
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }

                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 17
0
        private void Btn_printInvoice_Click(object sender, RoutedEventArgs e)
        {//print
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (MainWindow.groupObject.HasPermissionAction(reportsPermission, MainWindow.groupObjects, "one"))
                {
                    /////////////////////////////////////
                    if (invItemsLocations != null)
                    {
                        Thread t1 = new Thread(() =>
                        {
                            printInventory();
                        });
                        t1.Start();
                    }
                    //////////////////////////////////////
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 18
0
        private void Btn_print_Click(object sender, RoutedEventArgs e)
        {//print
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (MainWindow.groupObject.HasPermissionAction(reportsPermission, MainWindow.groupObjects, "one") || SectionData.isAdminPermision())
                {
                    #region
                    if (itemLocationListQuery != null)
                    {
                        BuildReport();
                        LocalReportExtensions.PrintToPrinterbyNameAndCopy(rep, MainWindow.rep_printer_name, short.Parse(MainWindow.rep_print_count));
                    }
                    #endregion
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 19
0
        private void Btn_exportToExcel_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                //export
                if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "report") || SectionData.isAdminPermision())
                {
                    this.Dispatcher.Invoke(() =>
                    {
                        Thread t1 = new Thread(FN_ExportToExcel);
                        t1.SetApartmentState(ApartmentState.STA);
                        t1.Start();
                    });
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 20
0
        private async void Btn_update_Click(object sender, RoutedEventArgs e)
        {//update
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "update") || SectionData.isAdminPermision())
                {
                    if (sysEmail.emailId > 0)
                    {
                        if (isValid())
                        {
                            sysEmail.email = tb_email.Text;
                            //   sysEmail.password = pb_password.Password;
                            sysEmail.password     = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(pb_password.Password));
                            sysEmail.name         = tb_name.Text;
                            sysEmail.port         = int.Parse(tb_port.Text);
                            sysEmail.isSSL        = tgl_isSSL.IsChecked;
                            sysEmail.isMajor      = tgl_isMajor.IsChecked;
                            sysEmail.smtpClient   = tb_smtpClient.Text;
                            sysEmail.side         = cb_side.SelectedValue.ToString();
                            sysEmail.branchId     = (int)cb_branchId.SelectedValue;
                            sysEmail.notes        = tb_notes.Text;
                            sysEmail.createUserId = MainWindow.userID;
                            sysEmail.updateUserId = MainWindow.userID;
                            //sysEmail.isActive = 1;
                            //  string s = await sysEmail.Save(sysEmail);
                            int s = await sysEmail.Save(sysEmail);

                            if (s.Equals(-4))
                            {
                                Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trMajorEmaillAlreadyExists"), animation: ToasterAnimation.FadeIn);
                            }
                            else if (!s.Equals(0))
                            {
                                Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopUpdate"), animation: ToasterAnimation.FadeIn);
                                await RefreshSysEmailList();

                                Tb_search_TextChanged(null, null);
                            }
                            else
                            {
                                Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                            }
                        }
                    }
                    else
                    {
                        Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trSelectItemFirst"), animation: ToasterAnimation.FadeIn);
                    }
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 21
0
        private async void Btn_destroy_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (MainWindow.groupObject.HasPermissionAction(destroyPermission, MainWindow.groupObjects, "one") || SectionData.isAdminPermision())
                {
                    bool valid = validateDistroy();
                    if (valid)
                    {
                        int    itemUnitId = 0;
                        int    itemId     = 0;
                        int    invoiceId  = 0;
                        string serialNum  = "";
                        if (invItemLoc.id != 0)
                        {
                            itemUnitId = invItemLoc.itemUnitId;
                            itemId     = invItemLoc.itemId;
                        }
                        else
                        {
                            itemUnitId = (int)cb_unit.SelectedValue;
                            itemId     = (int)cb_item.SelectedValue;
                        }
                        if (_ItemType == "sn")
                        {
                            serialNum = tb_serialNum.Text;
                        }
                        invItemLoc.cause = tb_reasonOfDestroy.Text;
                        invItemLoc.notes = tb_notes.Text;
                        if (lst_serials.Items.Count > 0)
                        {
                            for (int j = 0; j < lst_serials.Items.Count; j++)
                            {
                                serialNum += lst_serials.Items[j];
                                if (j != lst_serials.Items.Count - 1)
                                {
                                    serialNum += ",";
                                }
                            }
                        }
                        // decimal price = await invoiceModel.GetAvgItemPrice(itemUnitId, itemId);
                        decimal price = 0;
                        decimal total = 0;

                        #region invoice Object
                        invoiceModel.invNumber = await invoiceModel.generateInvNumber("ds", branchModel.code, MainWindow.branchID.Value);

                        invoiceModel.branchCreatorId = MainWindow.branchID.Value;
                        invoiceModel.posId           = MainWindow.posID.Value;
                        invoiceModel.createUserId    = MainWindow.userID.Value;
                        invoiceModel.invType         = "d"; // destroy
                        invoiceModel.paid            = 0;
                        invoiceModel.deserved        = invoiceModel.totalNet;
                        invoiceModel.notes           = tb_notes.Text;
                        if (cb_user.SelectedIndex != -1 && cb_user.SelectedIndex != 0)
                        {
                            invoiceModel.userId = (int)cb_user.SelectedValue;
                        }
                        #endregion
                        List <ItemTransfer> orderList = new List <ItemTransfer>();
                        #region notification Object
                        Notification not = new Notification()
                        {
                            title        = "trExceedMinLimitAlertTilte",
                            ncontent     = "trExceedMinLimitAlertContent",
                            msgType      = "alert",
                            createDate   = DateTime.Now,
                            updateDate   = DateTime.Now,
                            createUserId = MainWindow.userID.Value,
                            updateUserId = MainWindow.userID.Value,
                        };
                        #endregion
                        if (invItemLoc.id != 0)
                        {
                            price = (decimal)invItemLoc.avgPurchasePrice;
                            total = price * int.Parse(tb_amount.Text);
                            invoiceModel.total    = total;
                            invoiceModel.totalNet = total;
                            //int amount = await itemLocationModel.getAmountByItemLocId((int)invItemLoc.itemLocationId);
                            //if (amount >= invItemLoc.amountDestroyed)
                            //{
                            orderList.Add(new ItemTransfer()
                            {
                                itemName           = invItemLoc.itemName,
                                itemId             = invItemLoc.itemId,
                                unitName           = invItemLoc.unitName,
                                itemUnitId         = invItemLoc.itemUnitId,
                                quantity           = invItemLoc.amountDestroyed,
                                itemSerial         = serialNum,
                                price              = price,
                                invoiceId          = 0,
                                inventoryItemLocId = invItemLoc.id,
                                createUserId       = MainWindow.userID,
                            });
                            invoiceId = await invoiceModel.saveInvoice(invoiceModel);

                            if (invoiceId != 0)
                            {
                                invoiceModel.invoiceId = invoiceId;
                                await invoiceModel.saveInvoiceItems(orderList, invoiceId);

                                await invItemLoc.distroyItem(invItemLoc);

                                if (cb_user.SelectedIndex != -1 && cb_user.SelectedIndex != 0)
                                {
                                    await recordCash(invoiceModel);
                                }

                                await itemLocationModel.decreaseItemLocationQuantity((int)invItemLoc.itemLocationId, (int)invItemLoc.amountDestroyed, MainWindow.userID.Value, "storageAlerts_minMaxItem", not);
                                await refreshDestroyDetails();

                                Btn_clear_Click(null, null);
                                Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopAdd"), animation: ToasterAnimation.FadeIn);
                            }
                            else
                            {
                                Toaster.ShowError(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                            }

                            //}
                            //else
                            //{
                            //    Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trDestroyAmountMoreExist"), animation: ToasterAnimation.FadeIn);
                            //}
                        }
                        else
                        {
                            var avgPrice = items.Where(x => x.itemId == (int)cb_item.SelectedValue).Select(x => x.avgPurchasePrice).Single();
                            if (avgPrice != null)
                            {
                                price = (decimal)avgPrice;
                            }
                            total = price * int.Parse(tb_amount.Text);
                            invoiceModel.total    = total;
                            invoiceModel.totalNet = total;
                            orderList.Add(new ItemTransfer()
                            {
                                itemName     = cb_item.SelectedItem.ToString(),
                                itemId       = (int)cb_item.SelectedValue,
                                unitName     = cb_unit.SelectedItem.ToString(),
                                itemUnitId   = (int)cb_unit.SelectedValue,
                                quantity     = long.Parse(tb_amount.Text),
                                itemSerial   = serialNum,
                                price        = price,
                                cause        = tb_reasonOfDestroy.Text,
                                invoiceId    = 0,
                                createUserId = MainWindow.userID,
                            });
                            // اتلاف عنصر يدوياً بدون جرد
                            Window.GetWindow(this).Opacity = 0.2;
                            wd_transItemsLocation w;
                            w           = new wd_transItemsLocation();
                            w.orderList = orderList;
                            if (w.ShowDialog() == true)
                            {
                                if (w.selectedItemsLocations != null)
                                {
                                    List <ItemLocation> itemsLocations = w.selectedItemsLocations;
                                    List <ItemLocation> readyItemsLoc  = new List <ItemLocation>();

                                    // _ProcessType ="ex";
                                    for (int i = 0; i < itemsLocations.Count; i++)
                                    {
                                        if (itemsLocations[i].isSelected == true)
                                        {
                                            readyItemsLoc.Add(itemsLocations[i]);
                                        }
                                    }

                                    invoiceId = await invoiceModel.saveInvoice(invoiceModel);

                                    if (invoiceId != 0)
                                    {
                                        await invoiceModel.saveInvoiceItems(orderList, invoiceId);

                                        for (int i = 0; i < readyItemsLoc.Count; i++)
                                        {
                                            int itemLocId = readyItemsLoc[i].itemsLocId;
                                            int quantity  = (int)readyItemsLoc[i].quantity;
                                            await itemLocationModel.decreaseItemLocationQuantity(itemLocId, quantity, MainWindow.userID.Value, "storageAlerts_minMaxItem", not);
                                        }
                                        Btn_clear_Click(null, null);
                                        Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopAdd"), animation: ToasterAnimation.FadeIn);
                                    }
                                    else
                                    {
                                        Toaster.ShowError(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                                    }
                                }
                            }
                            Window.GetWindow(this).Opacity = 1;
                        }
                    }
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 22
0
        private void Btn_exportToExcel_Click(object sender, RoutedEventArgs e)
        {//export to excel
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (MainWindow.groupObject.HasPermissionAction(reportsPermission, MainWindow.groupObjects, "one") || SectionData.isAdminPermision())
                {
                    #region
                    if (invItemsQuery != null)
                    {
                        //    Thread t1 = new Thread(() =>
                        //{
                        List <ReportParameter> paramarr = new List <ReportParameter>();

                        string addpath;
                        bool   isArabic = ReportCls.checkLang();
                        if (isArabic)
                        {
                            addpath = @"\Reports\Store\Ar\ArDestroyReport.rdlc";
                        }
                        else
                        {
                            addpath = @"\Reports\Store\EN\DestroyReport.rdlc";
                        }
                        string reppath = reportclass.PathUp(Directory.GetCurrentDirectory(), 2, addpath);

                        ReportCls.checkLang();

                        clsReports.invItem(invItemsQuery, rep, reppath, paramarr);
                        clsReports.setReportLanguage(paramarr);
                        clsReports.Header(paramarr);

                        rep.SetParameters(paramarr);

                        rep.Refresh();
                        this.Dispatcher.Invoke(() =>
                        {
                            saveFileDialog.Filter = "EXCEL|*.xls;";
                            if (saveFileDialog.ShowDialog() == true)
                            {
                                string filepath = saveFileDialog.FileName;
                                LocalReportExtensions.ExportToExcel(rep, filepath);
                            }
                        });
                        //});
                        //    t1.Start();
                    }
                    #endregion
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 23
0
        private void Btn_preview_Click(object sender, RoutedEventArgs e)
        {//preview
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (MainWindow.groupObject.HasPermissionAction(reportsPermission, MainWindow.groupObjects, "one") || SectionData.isAdminPermision())
                {
                    #region
                    if (invItemsQuery != null)
                    {
                        Window.GetWindow(this).Opacity = 0.2;
                        string pdfpath = "";

                        List <ReportParameter> paramarr = new List <ReportParameter>();

                        pdfpath = @"\Thumb\report\temp.pdf";
                        pdfpath = reportclass.PathUp(Directory.GetCurrentDirectory(), 2, pdfpath);

                        string addpath;
                        bool   isArabic = ReportCls.checkLang();
                        if (isArabic)
                        {
                            addpath = @"\Reports\Store\Ar\ArDestroyReport.rdlc";
                        }
                        else
                        {
                            addpath = @"\Reports\Store\EN\DestroyReport.rdlc";
                        }
                        string reppath = reportclass.PathUp(Directory.GetCurrentDirectory(), 2, addpath);

                        ReportCls.checkLang();

                        clsReports.invItem(invItemsQuery, rep, reppath, paramarr);
                        clsReports.setReportLanguage(paramarr);
                        clsReports.Header(paramarr);

                        rep.SetParameters(paramarr);

                        rep.Refresh();

                        LocalReportExtensions.ExportToPDF(rep, pdfpath);
                        wd_previewPdf w = new wd_previewPdf();
                        w.pdfPath = pdfpath;
                        if (!string.IsNullOrEmpty(w.pdfPath))
                        {
                            w.ShowDialog();
                            w.wb_pdfWebViewer.Dispose();
                        }
                        Window.GetWindow(this).Opacity = 1;
                    }
                    #endregion
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
        private async void Btn_shortage_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (MainWindow.groupObject.HasPermissionAction(savePermission, MainWindow.groupObjects, "one") || SectionData.isAdminPermision())
                {
                    if (invItemLoc.id != 0)
                    {
                        bool valid = validateDistroy();
                        if (valid)
                        {
                            int    itemUnitId = 0;
                            int    itemId     = 0;
                            int    invoiceId  = 0;
                            string serialNum  = "";

                            itemUnitId           = invItemLoc.itemUnitId;
                            itemId               = invItemLoc.itemId;
                            invItemLoc.notes     = tb_notes.Text;
                            invItemLoc.fallCause = tb_reasonOfShortage.Text;
                            #region add invoice

                            //decimal price = await invoiceModel.GetAvgItemPrice(itemUnitId, itemId);
                            //price = Math.Round(price, 2);
                            decimal price = (decimal)invItemLoc.avgPurchasePrice;
                            decimal total = price * int.Parse(tb_amount.Text);

                            invoiceModel.invNumber = await invoiceModel.generateInvNumber("sh", branchModel.code, MainWindow.branchID.Value);

                            invoiceModel.branchCreatorId = MainWindow.branchID.Value;
                            invoiceModel.posId           = MainWindow.posID.Value;
                            invoiceModel.createUserId    = MainWindow.userID.Value;
                            invoiceModel.invType         = "sh"; // shortage
                            invoiceModel.total           = total;
                            invoiceModel.totalNet        = total;
                            invoiceModel.paid            = 0;
                            invoiceModel.deserved        = invoiceModel.totalNet;
                            invoiceModel.notes           = tb_notes.Text;

                            if (cb_user.SelectedIndex != -1 && cb_user.SelectedIndex != 0)
                            {
                                invoiceModel.userId = (int)cb_user.SelectedValue;
                            }
                            #endregion

                            List <ItemTransfer> orderList = new List <ItemTransfer>();
                            //int amount = await itemLocationModel.getAmountByItemLocId((int)invItemLoc.itemLocationId);
                            //if (amount >= invItemLoc.amount)
                            //{
                            if (_ItemType == "sn")
                            {
                                serialNum = tb_serialNum.Text;
                            }

                            if (lst_serials.Items.Count > 0)
                            {
                                for (int j = 0; j < lst_serials.Items.Count; j++)
                                {
                                    serialNum += lst_serials.Items[j];
                                    if (j != lst_serials.Items.Count - 1)
                                    {
                                        serialNum += ",";
                                    }
                                }
                            }

                            orderList.Add(new ItemTransfer()
                            {
                                itemName           = invItemLoc.itemName,
                                itemId             = invItemLoc.itemId,
                                unitName           = invItemLoc.unitName,
                                itemUnitId         = invItemLoc.itemUnitId,
                                quantity           = invItemLoc.amount,
                                itemSerial         = serialNum,
                                price              = price,
                                invoiceId          = 0,
                                inventoryItemLocId = invItemLoc.id,
                                createUserId       = MainWindow.userID,
                            });
                            invoiceId = await invoiceModel.saveInvoice(invoiceModel);

                            if (invoiceId != 0)
                            {
                                invoiceModel.invoiceId = invoiceId;
                                await invoiceModel.saveInvoiceItems(orderList, invoiceId);

                                await invItemLoc.fallItem(invItemLoc);

                                if (cb_user.SelectedIndex != -1 && cb_user.SelectedIndex != 0)
                                {
                                    await recordCash(invoiceModel);
                                }
                                await refreshShortageDetails();

                                Btn_clear_Click(null, null);
                                Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopAdd"), animation: ToasterAnimation.FadeIn);
                            }
                            else
                            {
                                Toaster.ShowError(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                            }
                            //}
                            //else
                            //{
                            //    Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trShortageAmountMoreExist"), animation: ToasterAnimation.FadeIn);
                            //}
                        }
                    }
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 25
0
        private void Btn_pdf_Click(object sender, RoutedEventArgs e)
        {//pdf
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "report") || SectionData.isAdminPermision())
                {
                    #region
                    if (sectionsQuery != null)
                    {
                        List <ReportParameter> paramarr = new List <ReportParameter>();

                        string addpath;
                        bool   isArabic = ReportCls.checkLang();
                        if (isArabic)
                        {
                            addpath = @"\Reports\Store\Ar\ArSectionReport.rdlc";
                        }
                        else
                        {
                            addpath = @"\Reports\Store\EN\SectionReport.rdlc";
                        }
                        string reppath = reportclass.PathUp(Directory.GetCurrentDirectory(), 2, addpath);

                        ReportCls.checkLang();

                        clsReports.section(sectionsQuery, rep, reppath);
                        clsReports.setReportLanguage(paramarr);
                        clsReports.Header(paramarr);

                        rep.SetParameters(paramarr);

                        rep.Refresh();

                        saveFileDialog.Filter = "PDF|*.pdf;";

                        if (saveFileDialog.ShowDialog() == true)
                        {
                            string filepath = saveFileDialog.FileName;
                            LocalReportExtensions.ExportToPDF(rep, filepath);
                        }
                    }
                    #endregion
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 26
0
        private async void Btn_update_Click(object sender, RoutedEventArgs e)
        {//update
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "update") || SectionData.isAdminPermision())
                {
                    if (storageCost.storageCostId > 0)
                    {
                        //chk empty name
                        SectionData.validateEmptyTextBox(tb_name, p_errorName, tt_errorName, "trEmptyNameToolTip");
                        //chk empty delivery cost
                        SectionData.validateEmptyTextBox(tb_cost, p_errorCost, tt_errorCost, "trEmptyStoreCost");

                        if ((!tb_name.Text.Equals("")) && (!tb_cost.Text.Equals("")))
                        {
                            storageCost.name         = tb_name.Text;
                            storageCost.cost         = decimal.Parse(tb_cost.Text);
                            storageCost.note         = tb_notes.Text;
                            storageCost.createUserId = MainWindow.userID;
                            //storageCost.isActive = 1;

                            int s = await storageCostModel.save(storageCost);

                            if (s > 0)
                            {
                                Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopUpdate"), animation: ToasterAnimation.FadeIn);

                                await RefreshStorageCostList();

                                Tb_search_TextChanged(null, null);
                            }
                            else
                            {
                                Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                            }
                        }
                    }
                    else
                    {
                        Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trSelectItemFirst"), animation: ToasterAnimation.FadeIn);
                    }
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 27
0
        private async void Btn_delete_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }
                //delete
                if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "delete") || SectionData.isAdminPermision())
                {
                    if (section.sectionId != 0)
                    {
                        if ((!section.canDelete) && (section.isActive == 0))
                        {
                            #region
                            Window.GetWindow(this).Opacity = 0.2;
                            wd_acceptCancelPopup w = new wd_acceptCancelPopup();
                            w.contentText = MainWindow.resourcemanager.GetString("trMessageBoxActivate");
                            w.ShowDialog();
                            Window.GetWindow(this).Opacity = 1;
                            #endregion
                            if (w.isOk)
                            {
                                await activate();
                            }
                        }
                        else
                        {
                            #region
                            Window.GetWindow(this).Opacity = 0.2;
                            wd_acceptCancelPopup w = new wd_acceptCancelPopup();
                            if (section.canDelete)
                            {
                                w.contentText = MainWindow.resourcemanager.GetString("trMessageBoxDelete");
                            }
                            if (!section.canDelete)
                            {
                                w.contentText = MainWindow.resourcemanager.GetString("trMessageBoxDeactivate");
                            }
                            w.ShowDialog();
                            Window.GetWindow(this).Opacity = 1;
                            #endregion
                            if (w.isOk)
                            {
                                string popupContent = "";
                                if (section.canDelete)
                                {
                                    popupContent = MainWindow.resourcemanager.GetString("trPopDelete");
                                }
                                if ((!section.canDelete) && (section.isActive == 1))
                                {
                                    popupContent = MainWindow.resourcemanager.GetString("trPopInActive");
                                }

                                int b = await sectionModel.delete(section.sectionId, MainWindow.userID.Value, section.canDelete);

                                if (b > 0)
                                {
                                    section.sectionId = 0;
                                    Toaster.ShowSuccess(Window.GetWindow(this), message: popupContent, animation: ToasterAnimation.FadeIn);
                                }
                                else
                                {
                                    Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                                }
                            }
                        }
                        await RefreshSectionsList();

                        Tb_search_TextChanged(null, null);
                    }
                    //clear textBoxs
                    Btn_clear_Click(sender, e);
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 28
0
        private async void Btn_add_Click(object sender, RoutedEventArgs e)
        {//add
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }
                if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "add") || SectionData.isAdminPermision())
                {
                    //validate values
                    validateEmptyValues();

                    if (!tb_name.Text.Equals(""))
                    {
                        // check if new unit doesn't match old units
                        var unitObj = units.ToList().Find(x => x.name == tb_name.Text);
                        if (unitObj is null)
                        {
                            unit = new Unit
                            {
                                name         = tb_name.Text,
                                notes        = tb_notes.Text,
                                createUserId = MainWindow.userID,
                                updateUserId = MainWindow.userID,
                                isActive     = 1,
                            };
                            int res = await unitModel.save(unit);

                            if (res > 0)
                            {
                                Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopAdd"), animation: ToasterAnimation.FadeIn);
                            }
                            else //SectionData.popUpResponse("", MainWindow.resourcemanager.GetString("trPopError"));
                            {
                                Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                            }

                            await RefreshUnitsList();

                            Tb_search_TextChanged(null, null);

                            Btn_clear_Click(null, null);
                        }
                        else
                        {
                            Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopUnitExist"), animation: ToasterAnimation.FadeIn);
                            p_errorName.Visibility = Visibility.Visible;
                            tt_errorName.Content   = MainWindow.resourcemanager.GetString("trPopUnitExist");
                            tb_name.Background     = (Brush)bc.ConvertFrom("#15FF0000");
                        }
                    }
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 29
0
        private async void Btn_add_Click(object sender, RoutedEventArgs e)
        {
            try
            {//add
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "add") || SectionData.isAdminPermision())
                {
                    if (validate(location))
                    {
                        location = new Location();
                        //location.locationId = 0;
                        location.x = tb_x.Text;
                        location.y = tb_y.Text;
                        location.z = tb_z.Text;
                        if (locations.Where(x => x.name == location.name && x.branchId == MainWindow.branchID).Count() == 0)
                        {
                            location.note         = tb_notes.Text;
                            location.createUserId = MainWindow.userID;
                            location.updateUserId = MainWindow.userID;
                            location.isActive     = 1;
                            location.sectionId    = null;
                            location.branchId     = MainWindow.branchID;

                            int s = await locationModel.save(location);

                            if (s > 0)
                            {
                                Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopAdd"), animation: ToasterAnimation.FadeIn);
                                Btn_clear_Click(null, null);
                            }
                            else
                            {
                                Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                            }

                            await RefreshLocationsList();

                            Tb_search_TextChanged(null, null);
                        }
                        else
                        {
                            Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trDublicateLocation"), animation: ToasterAnimation.FadeIn);
                        }
                    }
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Ejemplo n.º 30
0
        private async void Btn_update_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                //update
                if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "update") || SectionData.isAdminPermision())
                {
                    //chk empty name
                    SectionData.validateEmptyTextBox(tb_name, p_errorName, tt_errorName, "trEmptyNameToolTip");
                    //chk not exist
                    string txt     = tb_name.Text;
                    bool   isExist = medalsQuery.Any(i => i.name == tb_name.Text && i.medalId != medal.medalId);
                    if (isExist)
                    {
                        p_errorName.Visibility = Visibility.Visible;
                        tt_errorName.Content   = MainWindow.resourcemanager.GetString("trDublicateMedal");
                        tb_name.Background     = (Brush)bc.ConvertFrom("#15FF0000");
                    }
                    if ((!tb_name.Text.Equals("")) && !isExist)
                    {
                        int cashPoint = 0, invoiceCount = 0;
                        if (!tb_cashPointsRequired.Text.Equals(""))
                        {
                            cashPoint = Convert.ToInt32(tb_cashPointsRequired.Text);
                        }
                        if (!tb_invoiceCountPointsRequired.Text.Equals(""))
                        {
                            invoiceCount = Convert.ToInt32(tb_invoiceCountPointsRequired.Text);
                        }

                        medal.name  = tb_name.Text;
                        medal.notes = tb_notes.Text;
                        //medal.symbol = path_symbol.Data.ToString();
                        medal.CashPointsRequired         = cashPoint;
                        medal.invoiceCountPointsRequired = invoiceCount;
                        medal.createUserId = MainWindow.userID;
                        medal.isActive     = 1;

                        string s = await medalModel.Save(medal);

                        //MessageBox.Show(s);
                        if (!s.Equals("0"))
                        {
                            Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopUpdate"), animation: ToasterAnimation.FadeIn);
                        }
                        else
                        {
                            Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                        }

                        await RefreshMedalsList();

                        Tb_search_TextChanged(null, null);
                    }
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }