Esempio n. 1
0
 static async public void ExceptionMessage(Exception ex, object window)
 {
     try
     {
         //Message
         if (ex.HResult == -2146233088)
         {
             Toaster.ShowError(window as Window, message: MainWindow.resourcemanager.GetString("trNoInternetConnection"), animation: ToasterAnimation.FadeIn);
         }
         else
         {
             Toaster.ShowError(window as Window, message: ex.HResult + " || " + ex.Message, animation: ToasterAnimation.FadeIn);
         }
         ErrorClass errorClass = new ErrorClass();
         errorClass.num          = ex.HResult.ToString();
         errorClass.msg          = ex.Message;
         errorClass.stackTrace   = ex.StackTrace;
         errorClass.targetSite   = ex.TargetSite.ToString();
         errorClass.createUserId = MainWindow.userLogin.userId;
         await errorClass.Save(errorClass);
     }
     catch
     {
     }
 }
Esempio n. 2
0
        static async public void ExceptionMessage(Exception ex, object window)
        {
            try
            {
                //Message
                if (ex.HResult == -2146233088)
                {
                    Toaster.ShowError(window as Window, message: "trNoConnection", animation: ToasterAnimation.FadeIn);
                }
                else
                {
                    Toaster.ShowError(window as Window, message: ex.HResult + " || " + ex.Message, animation: ToasterAnimation.FadeIn);
                }

                //ErrorClass errorClass = new ErrorClass();
                //errorClass.num = ex.HResult.ToString();
                //errorClass.msg = ex.Message;
                //errorClass.stackTrace = ex.StackTrace;
                //errorClass.targetSite = ex.TargetSite.ToString();
                //errorClass.posId = MainWindow.posID;
                //errorClass.branchId = MainWindow.branchID;
                //errorClass.createUserId = MainWindow.userLogin.userId;
                //await errorClass.save(errorClass);
            }
            catch
            {
            }
        }
Esempio n. 3
0
        private async void deleteRowFromInvoiceItems(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_ucInvoice);
                }
                for (var vis = sender as Visual; vis != null; vis = VisualTreeHelper.GetParent(vis) as Visual)
                {
                    if (vis is DataGridRow)
                    {
                        #region
                        Window.GetWindow(this).Opacity = 0.2;
                        wd_acceptCancelPopup w = new wd_acceptCancelPopup();
                        w.contentText = MainWindow.resourcemanager.GetString("trMessageBoxDelete");
                        w.ShowDialog();
                        Window.GetWindow(this).Opacity = 1;
                        #endregion
                        if (w.isOk)
                        {
                            Invoice row = (Invoice)dg_Invoice.SelectedItems[0];
                            int     res = 0;
                            if (row.invType == "or")
                            {
                                res = await invoice.deleteOrder(row.invoiceId);
                            }
                            else
                            {
                                res = await invoice.deleteInvoice(row.invoiceId);
                            }
                            if (res > 0)
                            {
                                Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopDelete"), animation: ToasterAnimation.FadeIn);
                                await refreshInvoices();

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

                if (sender != null)
                {
                    SectionData.EndAwait(grid_ucInvoice);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_ucInvoice);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Esempio n. 4
0
        private async Task addInventory(string invType)
        {
            if (inventory.inventoryId == 0)
            {
                inventory.branchId     = MainWindow.branchID.Value;
                inventory.posId        = MainWindow.posID.Value;
                inventory.createUserId = MainWindow.userLogin.userId;
            }
            if (invType == "n")
            {
                inventory.num = await inventory.generateInvNumber("in", MainWindow.branchID.Value);
            }
            inventory.inventoryType = invType;
            inventory.updateUserId  = MainWindow.userLogin.userId;

            int inventoryId = await inventory.save(inventory);

            if (inventoryId != 0)
            {
                // add inventory details
                int res = await invItemModel.save(invItemsLocations, inventoryId);

                Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopAdd"), animation: ToasterAnimation.FadeIn);
                clearInventory();
            }
            else
            {
                Toaster.ShowError(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
            }
        }
Esempio n. 5
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);
                }
            }
        private async void Btn_save_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                bool valid = await validateInputs();

                if (valid)
                {
                    //int fromQuantity = int.Parse(tb_fromQuantity.Text);

                    if (cb_sectionLocation.SelectedIndex != -1)
                    {
                        var locationId = locations.Find(x => x.itemsLocId == (int)cb_sectionLocation.SelectedValue).locationId;
                        int res        = await ItemLocation.transferAmountbetweenUnits((int)locationId, (int)cb_sectionLocation.SelectedValue, (int)cb_toUnit.SelectedValue, _FromQuantity, _ToQuantity, MainWindow.userID.Value);

                        if (res > 0)
                        {
                            clearConversionInputs();
                            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
                    {
                        int res = await ItemLocation.unitsConversion(MainWindow.branchID.Value, (int)cb_fromUnit.SelectedValue, (int)cb_toUnit.SelectedValue, _FromQuantity, _ToQuantity, MainWindow.userID.Value, isSmall);

                        if (res > 0)
                        {
                            clearConversionInputs();
                            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);
                        }
                    }
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
        //************************************************
        //******************* 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);
            }
        }
Esempio n. 8
0
        private async void Btn_save_Click(object sender, RoutedEventArgs e)
        {//add
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                validateDocValues();
                if (!tb_name.Text.Equals(""))
                {
                    docId                    = 0;
                    docImgModel.id           = docId;
                    docImgModel.tableName    = tableName;
                    docImgModel.tableId      = tableId;
                    docImgModel.docnum       = docNum;
                    docImgModel.docName      = tb_name.Text;
                    docImgModel.note         = tb_notes.Text;
                    docImgModel.createUserId = MainWindow.userID;

                    int res = await docImgModel.saveDocImage(docImgModel);

                    if (!res.Equals(0))
                    {
                        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);
                    }

                    int docImageId = res;

                    // await docImgModel.uploadImage(openFileDialog.FileName, tableName, docImageId);
                    await docImgModel.uploadOrginalImage(openFileDialog.FileName, tableName, docImageId);

                    //refresh image list
                    await refreshImageList();

                    clear();
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Esempio n. 9
0
 public void OnNavigatedTo(NavigationEventArgs e)
 {
     try
     {
         Toaster.ShowError(ObjectHolder.MainForm, Status.Status_Head_CyberGhost_6, Alerts.SelectServer, 1, 0, 10.0);
     }
     catch (Exception ex)
     {
         LogHelper.LogMessage(string.Format("COULD NOT SHOW TOASTER {0}", ex.Message));
     }
 }
 public void OnNavigatedTo(NavigationEventArgs e)
 {
     try
     {
         Toaster.ShowError(ObjectHolder.MainForm, Status.Status_Head_CyberGhost_6, Status.SorryThereIsCurrentlyNoServerAvailableForThisProfilePleaseTryAgainInAFewMinutes, 1, 0, 10.0);
     }
     catch (Exception ex)
     {
         LogHelper.LogMessage(string.Format("COULD NOT SHOW TOASTER {0}", ex.Message));
     }
 }
Esempio n. 11
0
 public void OnNavigatedTo(NavigationEventArgs e)
 {
     try
     {
         Toaster.ShowError(ObjectHolder.MainForm, Status.Status_Head_CyberGhost_6, General.Splash_InitTheInit_Service_not_reachable, 1, 0, 10.0);
     }
     catch (Exception ex)
     {
         LogHelper.LogMessage(string.Format("COULD NOT SHOW TOASTER {0}", ex.Message));
     }
 }
Esempio n. 12
0
        private async void Btn_delete_Click(object sender, RoutedEventArgs e)
        {//delete
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (docImgModel.id != 0)
                {
                    int res = await docImgModel.delete(docId);

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

                    docId = 0;
                    //clear img
                    Uri resourceUri = new Uri("/pic/no-image-icon-125x125.png", UriKind.Relative);
                    StreamResourceInfo streamInfo = System.Windows.Application.GetResourceStream(resourceUri);
                    BitmapFrame        temp       = BitmapFrame.Create(streamInfo.Stream);
                    brush.ImageSource     = temp;
                    img_upload.Background = brush;

                    //refresh images
                    await refreshImageList();

                    clear();
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Esempio n. 13
0
        private async Task activate()
        {//activate
            unit.isActive = 1;

            int s = await unitModel.save(unit);

            if (s > 0)
            {
                Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopActive"), animation: ToasterAnimation.FadeIn);
            }
            else
            {
                Toaster.ShowError(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
            }
        }
Esempio n. 14
0
        private async Task activatePropertyItem()
        {//activate
            propertyItem.isActive = 1;
            propertyItem.name     = propertyItem.propertyItemName;

            int s = await propertiesItemsModel.save(propertyItem);

            if (s > 0)
            {
                Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopActive"), animation: ToasterAnimation.FadeIn);
            }
            else
            {
                Toaster.ShowError(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
            }
        }
Esempio n. 15
0
        private async void Btn_deleteInventory_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }
                if (inventory.inventoryId != 0)
                {
                    #region
                    Window.GetWindow(this).Opacity = 0.2;
                    wd_acceptCancelPopup w = new wd_acceptCancelPopup();
                    w.contentText = MainWindow.resourcemanager.GetString("trMessageBoxDelete");
                    w.ShowDialog();
                    Window.GetWindow(this).Opacity = 1;
                    #endregion
                    if (w.isOk)
                    {
                        int res = await inventory.delete(inventory.inventoryId, MainWindow.userID.Value, false);

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

                            clearInventory();
                        }
                        else
                        {
                            Toaster.ShowError(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                        }
                    }
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Esempio n. 16
0
        private async Task saveOrderStatus(int invoiceId, string status)
        {
            invoiceStatus st = new invoiceStatus();

            st.status       = status;
            st.invoiceId    = invoiceId;
            st.createUserId = MainWindow.userLogin.userId;
            st.isActive     = 1;
            int res = await invoice.saveOrderStatus(st);

            if (res > 0)
            {
                Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopConfirm"), animation: ToasterAnimation.FadeIn);
            }
            else
            {
                Toaster.ShowError(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
            }
        }
        private async void Btn_save_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_generatePackage);
                }

                bool valid = validateInputs();
                if (valid)
                {
                    int quantity = int.Parse(tb_quantity.Text);
                    int res      = await itemLocation.generatePackage(_PackageParentId, quantity, (int)cb_location.SelectedValue, MainWindow.branchID.Value, MainWindow.userID.Value);

                    if (res > 0)
                    {
                        clearGenerateInputs();
                        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);
                    }
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_generatePackage);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_generatePackage);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Esempio n. 18
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);
            }
        }
Esempio n. 19
0
 private void ShowError(object sender, RoutedEventArgs e)
 {
     Toaster.ShowError(this, title: TitleText.Text, message: MessageText.Text, position: (ToasterPosition)selectbox.SelectedItem, animation: (ToasterAnimation)aniselectbox.SelectedItem, margin: 20.0);
 }
        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);
            }
        }
Esempio n. 21
0
        private async void Btn_deleteValue_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }
                if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "delete") || SectionData.isAdminPermision())
                {
                    if ((!propertyItem.canDelete) && (propertyItem.isActive == 0))
                    {
                        await activatePropertyItem();
                    }
                    else
                    {
                        string popupContent = "";
                        if (propertyItem.canDelete)
                        {
                            popupContent = MainWindow.resourcemanager.GetString("trPopDelete");
                        }
                        if ((!propertyItem.canDelete) && (propertyItem.isActive == 1))
                        {
                            popupContent = MainWindow.resourcemanager.GetString("trPopInActive");
                        }
                        int userId = (int)MainWindow.userID;
                        int res    = await propertiesItemsModel.delete(propertyItem.propertyItemId, userId, propertyItem.canDelete);

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

                    var propertiesitems = await propertiesItemsModel.GetPropertyItems(property.propertyId);

                    dg_subProperty.ItemsSource = propertiesitems;
                }
                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);
            }
        }
Esempio n. 22
0
        private async void Btn_delete_Click(object sender, RoutedEventArgs e)
        {//delete
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }
                if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "delete") || SectionData.isAdminPermision())
                {
                    if ((!unit.canDelete) && (unit.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 (unit.canDelete)
                        {
                            w.contentText = MainWindow.resourcemanager.GetString("trMessageBoxDelete");
                        }
                        if (!unit.canDelete)
                        {
                            w.contentText = MainWindow.resourcemanager.GetString("trMessageBoxDeactivate");
                        }
                        w.ShowDialog();
                        Window.GetWindow(this).Opacity = 1;
                        #endregion
                        if (w.isOk)
                        {
                            string popupContent = "";
                            if (unit.canDelete)
                            {
                                popupContent = MainWindow.resourcemanager.GetString("trPopDelete");
                            }
                            if ((!unit.canDelete) && (unit.isActive == 1))
                            {
                                popupContent = MainWindow.resourcemanager.GetString("trPopInActive");
                            }
                            int userId = (int)MainWindow.userID;
                            int res    = await unitModel.delete(unit.unitId, userId, unit.canDelete);

                            if (res > 0)
                            {
                                unit.unitId = 0;
                                Toaster.ShowSuccess(Window.GetWindow(this), message: popupContent, animation: ToasterAnimation.FadeIn);
                            }
                            else
                            {
                                Toaster.ShowError(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.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);
            }
        }
Esempio n. 23
0
        private async void Btn_updateValue_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }
                if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "update") || SectionData.isAdminPermision())
                {
                    if (propertyItem.propertyItemId > 0)
                    {
                        //check mandatory values
                        var bc = new BrushConverter();
                        if (tb_valueName.Text.Equals(""))
                        {
                            p_errorNameSub.Visibility = Visibility.Visible;
                            tt_errorNameSub.Content   = MainWindow.resourcemanager.GetString("trEmptyNameToolTip");
                            tb_valueName.Background   = (Brush)bc.ConvertFrom("#15FF0000");
                        }
                        else
                        {
                            p_errorNameSub.Visibility = Visibility.Collapsed;
                            tb_valueName.Background   = (Brush)bc.ConvertFrom("#f8f8f8");
                        }
                        if (!tb_valueName.Text.Equals(""))
                        {
                            propertyItem.name             = tb_valueName.Text;
                            propertyItem.propertyItemName = tb_valueName.Text;
                            propertyItem.updateUserId     = MainWindow.userID;

                            int res = await propertiesItemsModel.save(propertyItem);

                            //          tb_valueName.Text = propertyItem.name;
                            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);
                            }

                            var propertiesItemss = await propertiesItemsModel.GetPropertyItems(property.propertyId);

                            dg_subProperty.ItemsSource = propertiesItemss;
                        }
                    }
                    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);
            }
        }
Esempio n. 24
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())
                {
                    var bc = new BrushConverter();
                    if (tb_name.Text.Equals(""))
                    {
                        p_errorNameSub.Visibility = Visibility.Visible;
                        tt_errorNameSub.Content   = MainWindow.resourcemanager.GetString("trEmptyNameToolTip");
                        tb_name.Background        = (Brush)bc.ConvertFrom("#15FF0000");
                    }
                    else
                    {
                        p_errorNameSub.Visibility = Visibility.Collapsed;
                        tb_name.Background        = (Brush)bc.ConvertFrom("#f8f8f8");
                    }
                    if (!tb_name.Text.Equals(""))
                    {
                        property = new Property
                        {
                            name         = tb_name.Text,
                            createUserId = 2,
                            updateUserId = 2,
                            isActive     = 1
                        };

                        int res = await propertyModel.save(property);

                        if (res > 0)
                        {
                            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);
                        }

                        //tb_name.Text = null;


                        await RefreshPropertiesList();

                        Tb_search_TextChanged(null, null);

                        //var properties = await propertyModel.getProperty();
                        //dg_property.ItemsSource = properties;
                    }
                }
                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);
            }
        }