Пример #1
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);
            }
        }
Пример #2
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);
            }
        }
Пример #3
0
        //************************************************
        //******************* delete property***************
        private async void Btn_delete_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }
                if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "delete") || SectionData.isAdminPermision())
                {
                    if ((!property.canDelete) && (property.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 activateProperty();
                        }
                    }
                    else
                    {
                        #region
                        Window.GetWindow(this).Opacity = 0.2;
                        wd_acceptCancelPopup w = new wd_acceptCancelPopup();
                        if (property.canDelete)
                        {
                            w.contentText = MainWindow.resourcemanager.GetString("trMessageBoxDelete");
                        }
                        if (!property.canDelete)
                        {
                            w.contentText = MainWindow.resourcemanager.GetString("trMessageBoxDeactivate");
                        }
                        w.ShowDialog();
                        Window.GetWindow(this).Opacity = 1;
                        #endregion
                        if (w.isOk)
                        {
                            string popupContent = "";
                            if (property.canDelete)
                            {
                                popupContent = MainWindow.resourcemanager.GetString("trPopDelete");
                            }
                            if ((!property.canDelete) && (property.isActive == 1))
                            {
                                popupContent = MainWindow.resourcemanager.GetString("trPopInActive");
                            }
                            int userId = (int)MainWindow.userID;
                            int res    = await propertyModel.delete(property.propertyId, userId, property.canDelete);

                            if (res > 0)
                            {
                                property.propertyId = 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 RefreshPropertiesList();

                    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);
            }
        }
Пример #4
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);
            }
        }
        private async void Btn_delete_Click(object sender, RoutedEventArgs e)
        {
            try
            {//delete
             //if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "delete"))
             //{
                HelpClass.StartAwait(grid_main);
                if (sysEmail.emailId != 0)
                {
                    if ((!sysEmail.canDelete) && (sysEmail.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 (sysEmail.canDelete)
                        {
                            w.contentText = MainWindow.resourcemanager.GetString("trMessageBoxDelete");
                        }
                        if (!sysEmail.canDelete)
                        {
                            w.contentText = MainWindow.resourcemanager.GetString("trMessageBoxDeactivate");
                        }
                        w.ShowDialog();
                        Window.GetWindow(this).Opacity = 1;
                        #endregion
                        if (w.isOk)
                        {
                            string popupContent = "";
                            if (sysEmail.canDelete)
                            {
                                popupContent = MainWindow.resourcemanager.GetString("trPopDelete");
                            }
                            if ((!sysEmail.canDelete) && (sysEmail.isActive == 1))
                            {
                                popupContent = MainWindow.resourcemanager.GetString("trPopInActive");
                            }

                            int s = await sysEmail.Delete(sysEmail.emailId, MainWindow.userLogin.userId, sysEmail.canDelete);

                            if (s < 0)
                            {
                                Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                            }
                            else
                            {
                                sysEmail.emailId = 0;
                                Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopDelete"), animation: ToasterAnimation.FadeIn);

                                await RefreshUsersList();
                                await Search();

                                Clear();
                            }
                        }
                    }
                }
                HelpClass.EndAwait(grid_main);
                //}
                //else
                //    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
            }
            catch (Exception ex)
            {
                HelpClass.EndAwait(grid_main);
                HelpClass.ExceptionMessage(ex, this);
            }
        }
        private async void Btn_upgrade_Click(object sender, RoutedEventArgs e)
        {                                                       //upgrade
            int    chk           = 0;
            string activationkey = progDetails.packageSaleCode; //get from info

            if (progDetails.isOnlineServer.Value)               //online
            {
                try
                {
                    if (activationkey.Trim() != "".Trim())
                    {
                        AvtivateServer ac = new AvtivateServer();

                        chk = await ac.checkconn();

                        chk = await ac.StatSendserverkey(activationkey, "up");

                        // //change      chk = 3;
                        //nochange     chk = 2;

                        if (chk <= 0)
                        {
                            string message = "inc(" + chk + ")";

                            string messagecode = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(message));

                            string msg = MainWindow.resourcemanager.GetString("trUpgradeNotCompleted") + "(" +
                                         MainWindow.resourcemanager.GetString("trErrorCode") + ":" + messagecode + ")";

                            Toaster.ShowWarning(Window.GetWindow(this), message: msg, animation: ToasterAnimation.FadeIn);
                        }

                        else
                        {
                            if (chk == 3)
                            {
                                Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trUpgradeCompleted"), animation: ToasterAnimation.FadeIn);
                                progDetails = await progDetailsModel.getCurrentInfo();

                                this.DataContext = progDetails;
                            }
                            else if (chk == 2)
                            {
                                Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trNoChanges"), animation: ToasterAnimation.FadeIn);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trServerNotFount"), animation: ToasterAnimation.FadeIn);
                }
            }
            else//offline
            {
                // start activate

                chk = 0;
                string message = "";
                try
                {
                    bool           isServerActivated = true;
                    AvtivateServer ac          = new AvtivateServer();
                    string         activeState = "up";
                    int            activematch = 0;

                    string filepath = "";
                    openFileDialog.Filter = "INC|*.ac; ";
                    SendDetail customerdata = new SendDetail();
                    SendDetail dc           = new SendDetail();
                    if (openFileDialog.ShowDialog() == true)
                    {
                        filepath = openFileDialog.FileName;

                        //   bool resr = ReportCls.decodefile(filepath, @"D:\stringlist.txt");//comment

                        string objectstr = "";

                        objectstr = ReportCls.decodetoString(filepath);

                        dc = JsonConvert.DeserializeObject <SendDetail>(objectstr, new JsonSerializerSettings {
                            DateParseHandling = DateParseHandling.None
                        });
                        packagesSend pss = new packagesSend();

                        pss = dc.packageSend;
                        isServerActivated = dc.packageSend.isServerActivated;
                        pss.activeApp     = "-";

                        dc.packageSend = pss;

                        // string activeState = "";
                        if (dc.packageSend.activeState == activeState)
                        {
                            activematch  = 1;
                            customerdata = await ac.OfflineActivate(dc, activeState);
                        }
                        else
                        {
                            Toaster.ShowWarning(Window.GetWindow(this), message: "The file isn't upgrade file", animation: ToasterAnimation.FadeIn);
                        }
                    }

                    // upload

                    if (activematch == 1)
                    {
                        if (customerdata.packageSend.result > 0)
                        {
                            // if first activate OR upgrade  show save dialoge to save customer data in file
                            saveFileDialog.Filter = "File|*.ac;";
                            if (saveFileDialog.ShowDialog() == true)
                            {
                                string DestPath = saveFileDialog.FileName;

                                string myContent = JsonConvert.SerializeObject(customerdata);

                                bool res = false;

                                res = ReportCls.encodestring(myContent, DestPath);

                                if (res)
                                {
                                    //     //done
                                    //   MessageBox.Show("Success");
                                    Toaster.ShowSuccess(Window.GetWindow(this), message: "Success", animation: ToasterAnimation.FadeIn);
                                }
                                else
                                {
                                    Toaster.ShowWarning(Window.GetWindow(this), message: "Error", animation: ToasterAnimation.FadeIn);
                                    //   MessageBox.Show("Error");
                                }
                            }
                        }
                        else
                        {
                            //   MessageBox.Show(customerdata.packageSend.result.ToString());
                            string msg = "NOT complete - " + customerdata.packageSend.result.ToString();
                            Toaster.ShowWarning(Window.GetWindow(this), msg, animation: ToasterAnimation.FadeIn);
                        }
                    }
                    else
                    {
                        //close
                    }

                    //end uploaa
                }
                catch (Exception ex)
                {
                    Toaster.ShowWarning(Window.GetWindow(this), message: "The server Not Found", animation: ToasterAnimation.FadeIn);
                }


                //end activate
            }
        }
Пример #7
0
        private async void Btn_upload_Click(object sender, RoutedEventArgs e)
        {
            //upload
            bool ress = AvtivateServer.validateUrl(tb_serverUri.Text);

            if (ress)
            {
                //int chk = await ac.checkconn();
                try
                {
                    validateEmptyTextBox(tb_serverUri, p_errorServerUri, tt_errorServerUri, "trEmptyError");
                    if (!tb_serverUri.Text.Equals(""))
                    {
                        // start activate
                        string t = Global.APIUri;//temp delete


                        string message = "";
                        try
                        {
                            if (tb_serverUri.Text.Trim() != "".Trim())
                            {
                                bool           isServerActivated = true;
                                AvtivateServer ac = new AvtivateServer();
                                Global.APIUri = tb_serverUri.Text + @"/api/";

                                string filepath = "";
                                openFileDialog.Filter = "INC|*.ac; ";
                                SendDetail customerdata = new SendDetail();
                                SendDetail dc           = new SendDetail();
                                if (openFileDialog.ShowDialog() == true)
                                {
                                    filepath = openFileDialog.FileName;

                                    //   bool resr = ReportCls.decodefile(filepath, @"D:\stringlist.txt");//comment

                                    string objectstr = "";

                                    objectstr = ReportCls.decodetoString(filepath);

                                    dc = JsonConvert.DeserializeObject <SendDetail>(objectstr, new JsonSerializerSettings {
                                        DateParseHandling = DateParseHandling.None
                                    });
                                    packagesSend pss = new packagesSend();

                                    pss = dc.packageSend;
                                    isServerActivated = dc.packageSend.isServerActivated;
                                    pss.activeApp     = "all";//no comment

                                    dc.packageSend = pss;

                                    // string activeState = "";
                                    customerdata = await ac.OfflineActivate(dc, "up");
                                }
                                // upload

                                if (customerdata.packageSend.result > 0)
                                {
                                    if (isServerActivated == false || (isServerActivated == true && dc.packageSend.activeState == "up"))
                                    {
                                        // if first activate OR upgrade  show save dialoge to save customer data in file
                                        saveFileDialog.Filter = "File|*.ac;";
                                        if (saveFileDialog.ShowDialog() == true)
                                        {
                                            string DestPath = saveFileDialog.FileName;

                                            string myContent = JsonConvert.SerializeObject(customerdata);

                                            bool res = false;

                                            res = ReportCls.encodestring(myContent, DestPath);

                                            if (res)
                                            {
                                                //     //done
                                                //   MessageBox.Show("Success");
                                                Toaster.ShowSuccess(Window.GetWindow(this), message: "Success", animation: ToasterAnimation.FadeIn);
                                            }
                                            else
                                            {
                                                Toaster.ShowWarning(Window.GetWindow(this), message: "Error", animation: ToasterAnimation.FadeIn);
                                                //   MessageBox.Show("Error");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        // if extend show extend result
                                        //renew no save

                                        Toaster.ShowSuccess(Window.GetWindow(this), message: "Success Extend", animation: ToasterAnimation.FadeIn);
                                    }
                                }
                                else
                                {
                                    //MessageBox.Show(customerdata.packageSend.result.ToString());
                                    Toaster.ShowWarning(Window.GetWindow(this), message: "Error-" + customerdata.packageSend.result.ToString(), animation: ToasterAnimation.FadeIn);
                                }
                                //end uploaa
                            }
                        }
                        catch (Exception ex)
                        {
                            Global.APIUri = t;//temp delete
                            Toaster.ShowWarning(Window.GetWindow(this), message: "The server Not Found", animation: ToasterAnimation.FadeIn);
                        }


                        //end activate

                        await Task.Delay(2000);

                        this.Close();
                    }
                }
                catch (Exception ex)
                {
                    Toaster.ShowWarning(Window.GetWindow(this), message: "The server Not Found", animation: ToasterAnimation.FadeIn);
                }
            }
            else
            {
                Toaster.ShowWarning(Window.GetWindow(this), message: "The server Not Found", animation: ToasterAnimation.FadeIn);
            }
        }
        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 (storageCost.storageCostId != 0)
                    {
                        if ((!storageCost.canDelete) && (storageCost.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 (storageCost.canDelete)
                            {
                                w.contentText = MainWindow.resourcemanager.GetString("trMessageBoxDelete");
                            }
                            if (!storageCost.canDelete)
                            {
                                w.contentText = MainWindow.resourcemanager.GetString("trMessageBoxDeactivate");
                            }
                            w.ShowDialog();
                            Window.GetWindow(this).Opacity = 1;
                            #endregion

                            if (w.isOk)
                            {
                                string popupContent = "";
                                if (storageCost.canDelete)
                                {
                                    popupContent = MainWindow.resourcemanager.GetString("trPopDelete");
                                }
                                if ((!storageCost.canDelete) && (storageCost.isActive == 1))
                                {
                                    popupContent = MainWindow.resourcemanager.GetString("trPopInActive");
                                }

                                int b = await storageCostModel.delete(storageCost.storageCostId, MainWindow.userID.Value, storageCost.canDelete);

                                if (b > 0)
                                {
                                    storageCost.storageCostId = 0;
                                    Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopDelete"), animation: ToasterAnimation.FadeIn);
                                }
                                else
                                {
                                    Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                                }
                            }
                        }

                        await RefreshStorageCostList();

                        Tb_search_TextChanged(null, null);

                        //clear textBoxs
                        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);
            }
        }
Пример #9
0
        async void cancelRowinDatagrid(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }
                for (var vis = sender as Visual; vis != null; vis = VisualTreeHelper.GetParent(vis) as Visual)
                {
                    if (vis is DataGridRow)
                    {
                        CashTransfer row = (CashTransfer)dg_transfers.SelectedItems[0];

                        #region get two pos
                        cashes2 = await cashModel.GetbySourcId("p", row.cashTransId);

                        //to insure that the pull operation is in cashtrans2
                        if (row.transType == "p")
                        {
                            cashtrans2 = cashes2.ToList()[0] as CashTransfer;
                            cashtrans3 = cashes2.ToList()[1] as CashTransfer;
                        }
                        else if (row.transType == "d")
                        {
                            cashtrans2 = cashes2.ToList()[1] as CashTransfer;
                            cashtrans3 = cashes2.ToList()[0] as CashTransfer;
                        }

                        #endregion

                        #region cancel
                        cashtrans2.isConfirm = 2;
                        cashtrans3.isConfirm = 2;

                        int s2 = await cashModel.Save(cashtrans2);

                        int s3 = await cashModel.Save(cashtrans3);

                        if ((!s2.Equals(0)) && (!s3.Equals(0)))
                        {
                            Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopCanceled"), animation: ToasterAnimation.FadeIn);
                            await fillDataGrid();
                        }
                        else
                        {
                            Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                        }
                        #endregion
                    }
                }

                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Пример #10
0
        private async void Btn_upload_Click(object sender, RoutedEventArgs e)
        {//upload
            try
            {
                HelpClass.StartAwait(grid_main);

                HelpClass.validateWindow(requiredControlList, this);
                if (cb_type.SelectedIndex != -1)
                {
                    PackageUser pumodel = new PackageUser();
                    //activeState = "up";
                    activeState = cb_type.SelectedValue.ToString();

                    if (activeState == "up")
                    {
                        string filepath = "";
                        openFileDialog.Filter = "INC|*.ac; ";

                        if (openFileDialog.ShowDialog() == true)
                        {
                            filepath = openFileDialog.FileName;

                            // bool resr = ReportCls.decodefile(filepath, @"D:\stringlist.txt");//comment
                            SendDetail dc        = new SendDetail();
                            string     objectstr = "";

                            objectstr = ReportCls.decodetoString(filepath);

                            dc = JsonConvert.DeserializeObject <SendDetail>(objectstr, new JsonSerializerSettings {
                                DateParseHandling = DateParseHandling.None
                            });

                            if (dc.packageSend.packageUserId == packageUser.packageUserId)
                            {
                                int res = await pumodel.updatecustomerdata(dc, activeState);

                                //   MessageBox.Show(res.ToString());
                                if (res > 0)
                                {
                                    if (res == 1)
                                    {
                                        // update done
                                        Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trRestoreDoneSuccessfuly"), animation: ToasterAnimation.FadeIn);
                                    }
                                    //else if (res == 2)
                                    //{
                                    //    //no update
                                    //    Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trRestoreNotComplete"), animation: ToasterAnimation.FadeIn);
                                    //}
                                }
                                else
                                {
                                    // error
                                    Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trRestoreNotComplete"), animation: ToasterAnimation.FadeIn);
                                }
                            }
                            else
                            {
                                // The File dosn't belong to this Package
                                Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trRestoreNotComplete") + "The File dosn't belong to this Package", animation: ToasterAnimation.FadeIn);
                            }
                        }
                        else
                        {
                            // error
                            Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trRestoreNotComplete"), animation: ToasterAnimation.FadeIn);
                        }
                    }
                }
                HelpClass.EndAwait(grid_main);
            }
            catch (Exception ex)
            {
                HelpClass.EndAwait(grid_main);
                HelpClass.ExceptionMessage(ex, this);
            }
        }
Пример #11
0
        private async void Btn_save_Click(object sender, RoutedEventArgs e)
        {//save
            try
            {
                HelpClass.StartAwait(grid_main);
                if (HelpClass.validateWindow(requiredControlList, this) && HelpClass.IsValidEmailWindow(this))
                {
                    tb_custCode.Text = await HelpClass.generateRandomString(5, "", "Customers", customerID);

                    customer.custCode  = tb_custCode.Text;
                    customer.custname  = tb_custname.Text;
                    customer.lastName  = tb_lastName.Text;
                    customer.countryId = Convert.ToInt32(cb_country.SelectedValue);
                    customer.email     = tb_email.Text;
                    customer.mobile    = cb_areaMobile.Text + "-" + tb_mobile.Text;
                    if (!tb_phone.Text.Equals(""))
                    {
                        customer.phone = cb_areaPhone.Text + "-" + cb_areaPhoneLocal.Text + "-" + tb_phone.Text;
                    }
                    if (!tb_fax.Text.Equals(""))
                    {
                        customer.fax = cb_areaFax.Text + "-" + cb_areaFaxLocal.Text + "-" + tb_fax.Text;
                    }
                    if (cb_custlevel.SelectedValue != null)
                    {
                        customer.custlevel = cb_custlevel.SelectedValue.ToString();
                    }
                    customer.company      = tb_company.Text;
                    customer.address      = tb_address.Text;
                    customer.notes        = tb_notes.Text;
                    customer.isActive     = 1;
                    customer.createUserId = MainWindow.userLogin.userId;
                    customer.updateUserId = MainWindow.userLogin.userId;

                    int s = await customer.Save(customer);

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

                        if (isImgPressed)
                        {
                            int    customerId = s;
                            string b          = await customer.uploadImage(imgFileName,
                                                                           Md5Encription.MD5Hash("Inc-m" + customerId.ToString()), customerId);

                            customer.image = b;
                            isImgPressed   = false;
                        }

                        isOk = true;
                        this.Close();
                    }
                }
                HelpClass.EndAwait(grid_main);
            }
            catch (Exception ex)
            {
                HelpClass.EndAwait(grid_main);
                HelpClass.ExceptionMessage(ex, this);
            }
        }
Пример #12
0
        private async void Btn_transfer_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (MainWindow.groupObject.HasPermissionAction(transferPermission, MainWindow.groupObjects, "one") || SectionData.isAdminPermision())
                {
                    if (dg_itemsStorage.SelectedIndex != -1)
                    {
                        validateMandatoryInputs();
                        if (itemLocation != null &&
                            !tb_quantity.Text.Equals("") && cb_section.SelectedIndex != -1 &&
                            cb_XYZ.SelectedIndex != -1 && (!itemLocation.itemType.Equals("d") ||
                                                           (itemLocation.itemType.Equals("d") && dp_startDate.SelectedDate != null && dp_endDate.SelectedDate != null)))
                        {
                            int oldLocationId = (int)itemLocation.locationId;
                            int newLocationId = (int)cb_XYZ.SelectedValue;
                            if (oldLocationId != newLocationId)
                            {
                                int          quantity    = int.Parse(tb_quantity.Text);
                                ItemLocation newLocation = new ItemLocation();
                                newLocation.itemUnitId   = itemLocation.itemUnitId;
                                newLocation.invoiceId    = itemLocation.invoiceId;
                                newLocation.locationId   = newLocationId;
                                newLocation.quantity     = quantity;
                                newLocation.startDate    = dp_startDate.SelectedDate;
                                newLocation.endDate      = dp_endDate.SelectedDate;
                                newLocation.note         = tb_notes.Text;
                                newLocation.updateUserId = MainWindow.userID.Value;
                                newLocation.createUserId = MainWindow.userID.Value;
                                //newLocation.storeCost
                                int res = await itemLocation.trasnferItem(itemLocation.itemsLocId, newLocation);

                                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);
                                }

                                if (chk_stored.IsChecked == true)
                                {
                                    await refreshItemsLocations();
                                }
                                else if (chk_freezone.IsChecked == true)
                                {
                                    await refreshFreeZoneItemsLocations();
                                }
                                else
                                {
                                }

                                clearInputs();
                            }
                            else
                            {
                                Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trTranseToSameLocation"), animation: ToasterAnimation.FadeIn);
                            }
                            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);
            }
        }
Пример #13
0
        private async void Btn_add_Click(object sender, RoutedEventArgs e)
        {//book
            try
            {
                HelpClass.StartAwait(grid_main);

                int msg = 0;

                string pop = "";
                if (HelpClass.validate(requiredControlList, this))
                {
                    packuser.packageId     = int.Parse(cb_package.SelectedValue.ToString());
                    packuser.userId        = agent.userId;
                    packuser.customerId    = int.Parse(cb_customer.SelectedValue.ToString());
                    packuser.createUserId  = MainWindow.userID;
                    packuser.packageNumber = await packuserModel.generateNumber("si", agent.code, agent.userId);

                    if (tgl_isActive.IsChecked == true)
                    {
                        packuser.isActive = 1;
                    }
                    else
                    {
                        packuser.isActive = 0;
                    }
                    if (tgl_device.IsChecked == true)
                    {
                        packuser.canChngSer = 1;
                    }
                    else
                    {
                        packuser.canChngSer = 0;
                    }

                    packuser.canRenew            = true;
                    packuser.packageSaleCode     = packuser.packageSaleCode;
                    packuser.notes               = "";
                    packuser.isOnlineServer      = bool.Parse(cb_isOnline.SelectedValue.ToString());
                    packuser.countryPackageId    = (int)cb_period.SelectedValue;
                    packuser.oldPackageId        = oldPackageId;
                    packuser.oldCountryPackageId = oldCountryPackageId;

                    if (packuser.packageUserId == 0)
                    {
                        pop = "trPopAddBook";
                    }
                    else
                    {
                        pop = "trPopUpgradeSucceed";
                    }

                    msg = await packuserModel.packageBook(packuser);

                    if (msg <= 0)
                    {
                        Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                    }
                    else
                    {
                        Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString(pop), animation: ToasterAnimation.FadeIn);
                        if (pop.Equals("trPopAddBook"))
                        {
                            Clear();
                        }
                    }
                }

                HelpClass.EndAwait(grid_main);
            }
            catch (Exception ex)
            {
                HelpClass.EndAwait(grid_main);
                HelpClass.ExceptionMessage(ex, this);
            }
        }
Пример #14
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 (pos.posId > 0)
                    {
                        #region validate
                        bool iscodeExist = await SectionData.isCodeExist(tb_code.Text, "", "Pos", pos.posId);

                        //chk empty name
                        SectionData.validateEmptyTextBox(tb_name, p_errorName, tt_errorName, "trEmptyNameToolTip");
                        //chk empty code
                        SectionData.validateEmptyTextBox(tb_code, p_errorCode, tt_errorCode, "trEmptyCodeToolTip");
                        //chk empty branch
                        SectionData.validateEmptyComboBox(cb_branch, p_errorSelectBranch, tt_errorSelectBranch, "trEmptyBranchToolTip");
                        #endregion
                        if ((!tb_name.Text.Equals("")) && (!tb_code.Text.Equals("")) && (!cb_branch.Text.Equals("")))
                        {
                            //duplicate
                            if (iscodeExist)
                            {
                                SectionData.validateDuplicateCode(tb_code, p_errorCode, tt_errorCode, "trDuplicateCodeToolTip");
                            }
                            else
                            {
                                pos.code         = tb_code.Text;
                                pos.name         = tb_name.Text;
                                pos.branchId     = Convert.ToInt32(cb_branch.SelectedValue);
                                pos.updateUserId = MainWindow.userID.Value;
                                pos.note         = tb_notes.Text;

                                int s = await posModel.save(pos);

                                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 RefreshPosList();

                                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);
            }
        }
Пример #15
0
        private async void Btn_save_Click(object sender, RoutedEventArgs e)
        {//save
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                #region validate
                bool emailError = false;
                if (!isFirstTime)
                {
                    //chk empty name
                    SectionData.validateEmptyTextBox(tb_name, p_errorName, tt_errorName, "trEmptyNameToolTip");
                    //validate email
                    SectionData.validateEmail(tb_email, p_errorEmail, tt_errorEmail);
                    if (!tb_email.Text.Equals(""))
                    {
                        if (!ValidatorExtensions.IsValid(tb_email.Text))
                        {
                            emailError = true;
                        }
                    }
                    //chk empty mobile
                    SectionData.validateEmptyTextBox(tb_mobile, p_errorMobile, tt_errorMobile, "trEmptyMobileToolTip");
                }
                else
                {
                    //chk empty name
                    validateEmptyTextBox(tb_name, p_errorName, tt_errorName, "Name cann't be empty");
                    //validate email
                    validateEmail(tb_email, p_errorEmail, tt_errorEmail);
                    if (!tb_email.Text.Equals(""))
                    {
                        if (!ValidatorExtensions.IsValid(tb_email.Text))
                        {
                            emailError = true;
                        }
                    }
                    //chk empty mobile
                    validateEmptyTextBox(tb_mobile, p_errorMobile, tt_errorMobile, "Mobile number cann't be empty");
                }
                #endregion

                #region save
                if ((!tb_name.Text.Equals("")) && (!tb_mobile.Text.Equals("")) && !emailError)
                {
                    //save name
                    if (!tb_name.Text.Equals(""))
                    {
                        setVName.value     = tb_name.Text;
                        setVName.isSystem  = 1;
                        setVName.isDefault = 1;
                        setVName.settingId = nameId;
                        // string sName = await valueModel.Save(setVName);
                        int sName = await valueModel.Save(setVName);

                        if (!sName.Equals(0))
                        {
                            MainWindow.companyName = tb_name.Text;
                        }
                    }
                    //save address
                    if (!tb_address.Text.Equals(""))
                    {
                        setVAddress.value     = tb_address.Text;
                        setVAddress.isSystem  = 1;
                        setVAddress.isDefault = 1;
                        setVAddress.settingId = addressId;
                        int sAddress = await valueModel.Save(setVAddress);

                        //   string sAddress = await valueModel.Save(setVAddress);
                        if (!sAddress.Equals(0))
                        {
                            MainWindow.Address = tb_address.Text;
                        }
                    }
                    //save email
                    if ((!tb_email.Text.Equals("")) && (!emailError))
                    {
                        setVEmail.value     = tb_email.Text;
                        setVEmail.isSystem  = 1;
                        setVEmail.settingId = emailId;
                        setVEmail.isDefault = 1;
                        //  string sEmail = await valueModel.Save(setVEmail);
                        int sEmail = await valueModel.Save(setVEmail);

                        if (!sEmail.Equals(0))
                        {
                            MainWindow.Email = tb_email.Text;
                        }
                    }
                    //save mobile
                    if (!tb_mobile.Text.Equals(""))
                    {
                        setVMobile.value     = cb_areaMobile.Text + "-" + tb_mobile.Text;
                        setVMobile.isSystem  = 1;
                        setVMobile.isDefault = 1;
                        setVMobile.settingId = mobileId;
                        int sMobile = await valueModel.Save(setVMobile);

                        if (!sMobile.Equals(0))
                        {
                            MainWindow.Mobile = cb_areaMobile.Text + tb_mobile.Text;
                        }
                    }
                    //save phone
                    if (!tb_phone.Text.Equals(""))
                    {
                        setVPhone.value     = cb_areaPhone.Text + "-" + cb_areaPhoneLocal.Text + "-" + tb_phone.Text;
                        setVPhone.isSystem  = 1;
                        setVPhone.isDefault = 1;
                        setVPhone.settingId = phoneId;
                        int sPhone = await valueModel.Save(setVPhone);

                        if (!sPhone.Equals(0))
                        {
                            MainWindow.Phone = cb_areaPhone.Text + cb_areaPhoneLocal.Text + tb_phone.Text;
                        }
                    }
                    //save fax
                    if (!tb_fax.Text.Equals(""))
                    {
                        setVFax.value     = cb_areaFax.Text + "-" + cb_areaFaxLocal.Text + "-" + tb_fax.Text;
                        setVFax.isSystem  = 1;
                        setVFax.isDefault = 1;
                        setVFax.settingId = faxId;
                        int sFax = await valueModel.Save(setVFax);

                        if (!sFax.Equals(0))
                        {
                            MainWindow.Fax = cb_areaFax.Text + cb_areaFaxLocal.Text + tb_fax.Text;
                        }
                    }
                    //  save logo
                    // image
                    //  string sLogo = "";
                    int sLogo = 0;
                    if (isImgPressed)
                    {
                        isImgPressed = false;

                        setVLogo.value     = sLogo.ToString();
                        setVLogo.isSystem  = 1;
                        setVLogo.isDefault = 1;
                        setVLogo.settingId = logoId;
                        sLogo = await valueModel.Save(setVLogo);

                        if (!sLogo.Equals(0))
                        {
                            MainWindow.logoImage = setVLogo.value;
                            string b = await setVLogo.uploadImage(imgFileName, Md5Encription.MD5Hash("Inc-m" + sLogo), sLogo);

                            setVLogo.value       = b;
                            MainWindow.logoImage = b;
                            sLogo = await valueModel.Save(setVLogo);

                            await valueModel.getImg(setVLogo.value);
                        }
                    }

                    #endregion
                    if (!isFirstTime)
                    {
                        Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopSave"), animation: ToasterAnimation.FadeIn);
                        await Task.Delay(1500);
                    }
                    this.Close();
                }
                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_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);
            }
        }
Пример #17
0
 private void ShowSuccess(object sender, RoutedEventArgs e)
 {
     Toaster.ShowSuccess(this, title: TitleText.Text, message: MessageText.Text, position: (ToasterPosition)selectbox.SelectedItem, animation: (ToasterAnimation)aniselectbox.SelectedItem, margin: 20.0);
 }
Пример #18
0
        private async void Btn_save_Click(object sender, RoutedEventArgs e)
        {//save
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                #region validate
                SectionData.validateEmptyComboBox(cb_firstLevel, p_errorFirstLevel, tt_errorFirstLevel, "trFirstPath");
                SectionData.validateEmptyComboBox(cb_secondLevel, p_errorSecondLevel, tt_errorSecondLevel, "trSecondPath");
                #endregion
                #region save
                if ((!cb_firstLevel.Text.Equals("")) && (!cb_firstLevel.Text.Equals("")))
                {
                    string first  = objects.Where(x => x.objectId == (int)cb_firstLevel.SelectedValue).FirstOrDefault().name.ToString();
                    string second = objects.Where(x => x.objectId == (int)cb_secondLevel.SelectedValue).FirstOrDefault().name.ToString();

                    //save first path
                    if (firstUserSetValue == null)
                    {
                        firstUserSetValue = new UserSetValues();
                    }

                    firstUserSetValue.userId       = MainWindow.userID;
                    firstUserSetValue.valId        = firstId;
                    firstUserSetValue.note         = first;
                    firstUserSetValue.createUserId = MainWindow.userID;
                    firstUserSetValue.updateUserId = MainWindow.userID;
                    int res1 = await userSetValuesModel.Save(firstUserSetValue);

                    //save second path
                    if (secondUserSetValue == null)
                    {
                        secondUserSetValue = new UserSetValues();
                    }

                    secondUserSetValue.userId       = MainWindow.userID;
                    secondUserSetValue.valId        = secondId;
                    secondUserSetValue.note         = second;
                    secondUserSetValue.createUserId = MainWindow.userID;
                    secondUserSetValue.updateUserId = MainWindow.userID;
                    int res2 = await userSetValuesModel.Save(secondUserSetValue);

                    if ((res1 > 0) && (res2 > 0))
                    {
                        Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopSave"), animation: ToasterAnimation.FadeIn);
                        MainWindow.firstPath  = first;
                        MainWindow.secondPath = second;
                        // MainWindow.first = res1;
//MainWindow.second = res2;
                        await Task.Delay(1500);

                        this.Close();
                    }
                    else
                    {
                        Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                    }
                }
                #endregion
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
            //+ $"Second: {objects.Where(x => x.objectId == (int)cb_secondLevel.SelectedValue).FirstOrDefault().name}");
        }
Пример #19
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 (card.cardId > 0)
                    {
                        //chk empty name
                        SectionData.validateEmptyTextBox(tb_name, p_errorName, tt_errorName, "trEmptyNameToolTip");
                        if ((!tb_name.Text.Equals("")))
                        {
                            bool isCardExist = await chkDuplicateCard();

                            if (isCardExist)
                            {
                                Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopCardExist"), animation: ToasterAnimation.FadeIn);
                                p_errorName.Visibility = Visibility.Visible;
                                tt_errorName.Content   = MainWindow.resourcemanager.GetString("trPopCardExist");
                                tb_name.Background     = (Brush)bc.ConvertFrom("#15FF0000");
                            }
                            else
                            {
                                card.name          = tb_name.Text;
                                card.hasProcessNum = tgl_hasProcessNum.IsChecked;
                                card.notes         = tb_notes.Text;
                                card.createUserId  = MainWindow.userID;
                                card.updateUserId  = MainWindow.userID;
                                //card.isActive = active;

                                int s = await cardModel.save(card);

                                //if (s.Equals("true"))
                                if (s > 0)
                                {
                                    Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopUpdate"), animation: ToasterAnimation.FadeIn);
                                    if (isImgPressed)
                                    {
                                        int    cardId = s;
                                        string b      = await cardModel.uploadImage(imgFileName, Md5Encription.MD5Hash("Inc-m" + cardId.ToString()), cardId);

                                        card.image   = b;
                                        isImgPressed = false;
                                        if (!b.Equals(""))
                                        {
                                            getImg();
                                        }
                                        else
                                        {
                                            SectionData.clearImg(img_card);
                                        }
                                    }
                                }
                                else
                                {
                                    Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                                }

                                await RefreshCardsList();

                                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);
            }
        }