コード例 #1
0
        private async void Btn_update_Click(object sender, RoutedEventArgs e)
        {//update
            try
            {
                HelpClass.StartAwait(grid_main);
                if (sysEmail.emailId > 0)
                {
                    if (HelpClass.validate(requiredControlList, this) && HelpClass.IsValidEmail(this))
                    {
                        sysEmail.email = tb_email.Text;
                        //   sysEmail.password = pb_password.Password;
                        sysEmail.password     = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(pb_password.Password));
                        sysEmail.name         = tb_name.Text;
                        sysEmail.port         = int.Parse(tb_port.Text);
                        sysEmail.isSSL        = tgl_isSSL.IsChecked.Value;
                        sysEmail.isMajor      = true;
                        sysEmail.smtpClient   = tb_smtpClient.Text;
                        sysEmail.side         = cb_side.SelectedValue.ToString();
                        sysEmail.branchId     = 1;
                        sysEmail.notes        = tb_notes.Text;
                        sysEmail.createUserId = MainWindow.userLogin.userId;
                        sysEmail.updateUserId = MainWindow.userLogin.userId;
                        //sysEmail.isActive = 1;
                        //  string s = await sysEmail.Save(sysEmail);
                        int s = await sysEmail.Save(sysEmail);

                        if (s.Equals(-4))
                        {
                            Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trMajorEmaillAlreadyExists"), animation: ToasterAnimation.FadeIn);
                        }
                        else if (!s.Equals(0))
                        {
                            Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopUpdate"), animation: ToasterAnimation.FadeIn);
                            await RefreshUsersList();
                            await Search();
                        }
                        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);
                }



                HelpClass.EndAwait(grid_main);
            }
            catch (Exception ex)
            {
                HelpClass.EndAwait(grid_main);
                HelpClass.ExceptionMessage(ex, this);
            }
        }
コード例 #2
0
        private async void Btn_update_Click(object sender, RoutedEventArgs e)
        {//update
            try
            {
                HelpClass.StartAwait(grid_main);
                if (user.userId > 0)
                {
                    //chk duplicate userName
                    bool duplicateUserName = false;
                    duplicateUserName = await chkIfUserNameIsExists(tb_name.Text, user.userId);

                    if (HelpClass.validate(requiredControlList, this) && duplicateUserName && HelpClass.IsValidEmail(this))
                    {
                        user.name        = tb_name.Text;
                        user.lastName    = tb_lastName.Text;
                        user.countryId   = Convert.ToInt32(cb_country.SelectedValue);
                        user.accountName = tb_accountName.Text;
                        //user.password = Md5Encription.MD5Hash("Inc-m" + pb_password.Password); ;
                        user.email  = tb_email.Text;
                        user.mobile = cb_areaMobile.Text + "-" + tb_mobile.Text;;
                        if (!tb_phone.Text.Equals(""))
                        {
                            user.phone = cb_areaPhone.Text + "-" + cb_areaPhoneLocal.Text + "-" + tb_phone.Text;
                        }
                        if (!tb_fax.Text.Equals(""))
                        {
                            user.fax = cb_areaFax.Text + "-" + cb_areaFaxLocal.Text + "-" + tb_fax.Text;
                        }
                        if (cb_agentLevel.SelectedValue != null)
                        {
                            user.agentLevel = cb_agentLevel.SelectedValue.ToString();
                        }
                        user.address      = tb_address.Text;
                        user.notes        = tb_notes.Text;
                        user.createUserId = MainWindow.userLogin.userId;
                        user.updateUserId = MainWindow.userLogin.userId;

                        int s = await user.Save(user);

                        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("trPopUpdate"), animation: ToasterAnimation.FadeIn);
                            await RefreshUsersList();
                            await Search();

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

                                user.image   = b;
                                isImgPressed = false;
                                if (!b.Equals(""))
                                {
                                    await getImg();
                                }
                                else
                                {
                                    HelpClass.clearImg(btn_image);
                                }
                            }
                        }
                    }
                }
                else
                {
                    Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trSelectItemFirst"), animation: ToasterAnimation.FadeIn);
                }

                HelpClass.EndAwait(grid_main);
            }
            catch (Exception ex)
            {
                HelpClass.EndAwait(grid_main);
                HelpClass.ExceptionMessage(ex, this);
            }
        }
コード例 #3
0
        private async void Btn_add_Click(object sender, RoutedEventArgs e)
        {//add
            try
            {
                HelpClass.StartAwait(grid_main);

                //chk duplicate userName
                bool duplicateUserName = false;
                duplicateUserName = await chkIfUserNameIsExists(tb_name.Text, 0);

                //chk password length
                bool passLength = false;
                passLength = chkPasswordLength(pb_password.Password);

                user = new Users();
                if (HelpClass.validate(requiredControlList, this) && duplicateUserName && passLength && HelpClass.IsValidEmail(this))
                {
                    //tb_code.Text = await user.generateCodeNumber("ag");
                    tb_code.Text = await HelpClass.generateRandomString(3, "ag", "Users", 0);

                    user.code        = tb_code.Text;
                    user.name        = tb_name.Text;
                    user.lastName    = tb_lastName.Text;
                    user.countryId   = Convert.ToInt32(cb_country.SelectedValue);
                    user.accountName = tb_accountName.Text;
                    user.password    = Md5Encription.MD5Hash("Inc-m" + pb_password.Password);;
                    user.email       = tb_email.Text;
                    user.mobile      = cb_areaMobile.Text + "-" + tb_mobile.Text;;
                    if (!tb_phone.Text.Equals(""))
                    {
                        user.phone = cb_areaPhone.Text + "-" + cb_areaPhoneLocal.Text + "-" + tb_phone.Text;
                    }
                    if (!tb_fax.Text.Equals(""))
                    {
                        user.fax = cb_areaFax.Text + "-" + cb_areaFaxLocal.Text + "-" + tb_fax.Text;
                    }
                    if (cb_agentLevel.SelectedValue != null)
                    {
                        user.agentLevel = cb_agentLevel.SelectedValue.ToString();
                    }
                    user.type         = "ag";
                    user.address      = tb_address.Text;
                    user.notes        = tb_notes.Text;
                    user.isActive     = 1;
                    user.createUserId = MainWindow.userLogin.userId;
                    user.updateUserId = MainWindow.userLogin.userId;

                    int s = await user.Save(user);

                    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("trPopAdd"), animation: ToasterAnimation.FadeIn);

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

                            user.image   = b;
                            isImgPressed = false;
                        }

                        Clear();
                        await RefreshUsersList();
                        await Search();
                    }
                }

                HelpClass.EndAwait(grid_main);
            }
            catch (Exception ex)
            {
                HelpClass.EndAwait(grid_main);
                HelpClass.ExceptionMessage(ex, this);
            }
        }
コード例 #4
0
        private async void Btn_add_Click(object sender, RoutedEventArgs e)
        {//add
            try
            {
                HelpClass.StartAwait(grid_main);
                customer = new Customers();
                if (HelpClass.validate(requiredControlList, this) && HelpClass.IsValidEmail(this))
                {
                    //tb_custCode.Text = await customer.generateCodeNumber("cu");
                    tb_custCode.Text = await HelpClass.generateRandomString(5, "", "Customers", 0);

                    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.Trim();
                    customer.address      = tb_address.Text;
                    customer.notes        = tb_notes.Text;
                    customer.isActive     = 1;
                    customer.createUserId = MainWindow.userLogin.userId;
                    customer.updateUserId = MainWindow.userLogin.userId;
                    customer.balance      = 0;

                    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("trPopAdd"), 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;
                        }

                        Clear();
                        await RefreshCustomersList();
                        await Search();
                    }
                }
                HelpClass.EndAwait(grid_main);
            }
            catch (Exception ex)
            {
                HelpClass.EndAwait(grid_main);
                HelpClass.ExceptionMessage(ex, this);
            }
        }
コード例 #5
0
        private async void Btn_save_Click(object sender, RoutedEventArgs e)
        {//save
            try
            {
                if (sender != null)
                {
                    HelpClass.StartAwait(grid_main);
                }

                #region validate
                if (HelpClass.validate(requiredControlList, this) && HelpClass.IsValidEmail(this))
                {
                    //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))
                        {
                            FillCombo.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))
                        {
                            FillCombo.Address = tb_address.Text;
                        }
                    }
                    //save email
                    if ((!tb_email.Text.Equals("")))
                    {
                        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))
                        {
                            FillCombo.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))
                        {
                            FillCombo.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))
                    {
                        FillCombo.Phone = cb_areaPhone.Text + cb_areaPhoneLocal.Text + tb_phone.Text;
                    }
                    //}
                    //save fax

                    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))
                    {
                        FillCombo.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))
                        {
                            FillCombo.logoImage = setVLogo.value;
                            string b = await setVLogo.uploadImage(imgFileName, Md5Encription.MD5Hash("Inc-m" + sLogo), sLogo);

                            setVLogo.value      = b;
                            FillCombo.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);
                    }
                    await FillCombo.loading_getDefaultSystemInfo();

                    this.Close();
                }
                if (sender != null)
                {
                    HelpClass.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    HelpClass.EndAwait(grid_main);
                }
                HelpClass.ExceptionMessage(ex, this);
            }
        }