예제 #1
0
        private void newuser_Click(object sender, RoutedEventArgs e)
        {
            // ShowUserInfo(searchstate);



            try
            {
                Members U   = new Members();
                Submit  Sub = new Submit();
                // text box ro be sorate automatic bebarim ye mah bad va age motaqaier b on rooz resid bege qeir faal an
                int    bedehs;
                string descs;

                LinkBedehi l = new LinkBedehi();


                if (BedehiDescText.Text == " را اینجا وارد کنید")
                {
                    descs = "توضیح این بدهی وجود ندارد";
                }
                else
                {
                    descs = BedehiDescText.Text;
                }
                if (Convert.ToDecimal(BedehiText.Text) == 50)
                {
                    bedehs = 0;
                }
                else
                {
                    bedehs = 2;
                }


                U.MemberFactorCode = Convert.ToInt64(TextBoxFactor.Text.Trim());
                U.MemberFindID     = Convert.ToInt32(txt_username.Text.Trim());


                U.MemberDesc      = TozihTextBox.Text == "توضیحات این فاکتور را بنویسید." ? "فاکتور خرید" : TozihTextBox.Text;
                U.BedehKariDesc   = TozihTextBox.Text == "توضیحات این فاکتور را بنویسید." ? "فاکتور خرید" : TozihTextBox.Text;
                U.MemberCharge    = Convert.ToDecimal(UserCharge.Text.Trim());
                U.MemberCharge    = Convert.ToDecimal(UserCharge.Text.Trim());
                U.UserBedehiRial  = Convert.ToDecimal(BedehiText.Text.Trim()) == 50 ? 0 : Convert.ToDecimal(BedehiText.Text.Trim());
                U.MemberService   = Convert.ToByte(bedehs);
                U.MemberStartDate = String.Format("{0:yyyy/MM/dd}", Convert.ToDateTime(Lbl_Name_Copy.Content));


                database.Members.Add(U);
                database.SaveChanges();
                SucFul Suc = new SucFul();

                Suc.Show();
                Suc.Suclbl.Content = "فاکتور با موفقیت ثبت شد";
            }
            catch
            {
                ErrorPage E = new ErrorPage();
                E.Show();
                E.Error_Lable.Content = "کد کاربری درستی وارد کنید";
                txt_username.Focus();
            }
        }
예제 #2
0
        private void newuser_Click(object sender, RoutedEventArgs e)
        {
            Form2 F1 = new Form2();

            if (!Cheakable())
            {
                return;
            }
            try
            {
                int mount = Taghvim.SelectedDate.Month;
                int day   = Taghvim.SelectedDate.Day;
                int year  = Taghvim.SelectedDate.Year;

                string Year2 = year + "/" + mount + "/" + day;


                if (Hanis.SelectedIndex == 0)
                {
                    PayaneCharge.SelectedDate = PersianDate.Today.AddDays(30);

                    Year2 = year + "/" + (mount + 1) + "/" + day;
                }
                else if (Hanis.SelectedIndex == 1)
                {
                    PayaneCharge.SelectedDate = PersianDate.Today.AddDays(60);
                    Year2 = year + "/" + (mount + 2) + "/" + day;
                }
                else if (Hanis.SelectedIndex == 2)
                {
                    PayaneCharge.SelectedDate = PersianDate.Today.AddDays(90);
                    Year2 = year + "/" + (mount + 3) + "/" + day;
                }
                else if (Hanis.SelectedIndex == 3)
                {
                    PayaneCharge.SelectedDate = PersianDate.Today.AddDays(120);

                    Year2 = year + "/" + (mount + 4) + "/" + day;
                }
                else if (Hanis.SelectedIndex == 4)
                {
                    Year2 = year + "/" + (mount + 6) + "/" + day;
                    PayaneCharge.SelectedDate = PersianDate.Today.AddDays(180);
                }
                else if (Hanis.SelectedIndex == 5)
                {
                    Year2 = (year + 1) + "/" + mount + "/" + day;
                    PayaneCharge.SelectedDate = PersianDate.Today.AddDays(360);
                }



                SHA256CryptoServiceProvider Sha2 = new SHA256CryptoServiceProvider();


                byte[] B1;
                byte[] B2;
                B1 = UTF8Encoding.UTF8.GetBytes(UserPassword.Text);
                B2 = Sha2.ComputeHash(B1);
                string UserPasswordHashed = BitConverter.ToString(B2);

                VW_Users U = new VW_Users();
                byte     estakhr, bime, khososi, barnameqazaiy;
                if (EstakhrCheakBox.IsChecked == true)
                {
                    estakhr = 1;
                }
                else
                {
                    estakhr = 0;
                }

                if (BimeCheakBox.IsChecked == true)
                {
                    bime = 1;
                }
                else
                {
                    bime = 0;
                }

                if (KhososiCheakBox.IsChecked == true)
                {
                    khososi = 1;
                }
                else
                {
                    khososi = 0;
                }
                if (BarnameQazaiCheakBox.IsChecked == true)
                {
                    barnameqazaiy = 1;
                }
                else
                {
                    barnameqazaiy = 0;
                }

                if (NoeVarzesh.SelectedIndex == 0)
                {
                    U.UserKarKard = 1;
                }
                else
                {
                    U.UserKarKard = 2;
                }
                if (UserTamrin.SelectedIndex == 0)
                {
                    U.UserTamrin = 1;
                }
                else
                {
                    U.UserKarKard = 2;
                }
                if (rdb_man.IsChecked == true)
                {
                    U.UserGender = 1;
                }
                else
                {
                    U.UserGender = 2;
                }
                if (ImageName != "")
                {
                    FileStream fs         = new FileStream(ImageName, FileMode.Open, FileAccess.Read);
                    byte[]     imgByteArr = new byte[fs.Length];
                    fs.Read(imgByteArr, 0, Convert.ToInt32(fs.Length));
                    fs.Close();
                    database.Sp_gym(Username.Text.Trim(), UserFamily.Text.Trim(), UserTel.Text.Trim(), UserUsername.Text.Trim(),
                                    UserPasswordHashed.ToString(), Convert.ToByte(UserAge.Text.Trim()), 1, U.UserGender, UserCode.Text.Trim(), UserLocation.Text.Trim(), UserHomePhone.Text.Trim(),
                                    UserDoreSine.Text.Trim(), UserBazu.Text.Trim(), UserKamar.Text.Trim(), UserGhad.Text.Trim(), UserVazn.Text.Trim(), U.UserTamrin, U.UserKarKard, U.UserShahrie, String.Format("{0:yyyy/MM/dd}", Convert.ToDateTime(Year2)),
                                    " ", UserCodePost.Text.Trim(), /*cAccCreditDate.Text.ToString()*/ null, UserCharge.Text.Trim(), Convert.ToDecimal(UserCharge.Text.Trim()), 1, Komod.Text, imgByteArr, Convert.ToBoolean(estakhr), Convert.ToBoolean(bime), Convert.ToBoolean(khososi), Convert.ToBoolean(barnameqazaiy));



                    database.SaveChanges();
                    SucFul ER = new SucFul();
                    ER.Show();
                    ER.Suclbl.Content = "کاربر جدید ثبت شد";
                }

                else
                {
                    database.Sp_gym(Username.Text.Trim(), UserFamily.Text.Trim(), UserTel.Text.Trim(), UserUsername.Text.Trim(),
                                    UserPasswordHashed.ToString(), Convert.ToByte(UserAge.Text.Trim()), 1, U.UserGender, UserCode.Text.Trim(), UserLocation.Text.Trim(), UserHomePhone.Text.Trim(),
                                    UserDoreSine.Text.Trim(), UserBazu.Text.Trim(), UserKamar.Text.Trim(), UserGhad.Text.Trim(), UserVazn.Text.Trim(), U.UserTamrin, U.UserKarKard, U.UserShahrie, String.Format("{0:yyyy/MM/dd}", Convert.ToDateTime(Year2)),
                                    " ", UserCodePost.Text.Trim(), /*cAccCreditDate.Text.ToString()*/ null, UserCharge.Text.Trim(), Convert.ToDecimal(UserCharge.Text.Trim()), 1, Komod.Text.Trim(), null, Convert.ToBoolean(estakhr), Convert.ToBoolean(bime), Convert.ToBoolean(khososi), Convert.ToBoolean(barnameqazaiy));
                    database.SaveChanges();

                    SucFul ER = new SucFul();
                    ER.Show();
                    ER.Suclbl.Content = "کاربر جدید ثبت شد";
                }



                Members Us  = new Members();
                Submit  Sub = new Submit();


                LinkBedehi l = new LinkBedehi();


                SqlConnection con1 = new SqlConnection(PublicVar.ConnectionString);
                con1.Open();
                SqlCommand FactorCode       = new SqlCommand("select MAX(UserID) FROM Users", con1);
                object     FactorCodeObj    = FactorCode.ExecuteScalar();
                string     FactorCodeString = Convert.ToString(FactorCodeObj);

                Us.MemberFactorCode = Convert.ToInt64(UserFactor.Text.Trim());
                Us.MemberFindID     = Convert.ToInt32(FactorCodeString);
                Us.MemberStartDate  = PublicVar.TodayTime;
                Us.MemberLastCharge = String.Format("{0:yyyy/MM/dd}", Convert.ToDateTime(Year2));



                int timeInFactor = DateTimeHidden.SelectedDate.Month;
                int payanTime    = PayaneCharge.SelectedDate.Month;
                Us.MemberMounth   = Convert.ToByte(timeInFactor);
                Us.MemberMountTwo = Convert.ToByte(payanTime);



                Us.MemberCharge   = Convert.ToDecimal(UserCharge.Text.Trim());
                Us.UserBedehiRial = 0;
                Us.BedehKariDesc  = "ثبت نام";
                // Us.MemberService = Convert.ToByte(bedehs);



                database.Members.Add(Us);



                UsersTimeOut T = new UsersTimeOut();

                T.UserFindID  = Convert.ToInt32(FactorCodeString);
                T.UserEndDate = String.Format("{0:yyyy/MM/dd}", Convert.ToDateTime(Year2));

                database.UsersTimeOut.Add(T);
                database.SaveChanges();
            }


            catch (Exception ex)
            {
                ErrorPage ER = new ErrorPage();
                ER.Show();
                ER.Error_Lable.Content = ex.ToString();
            }
            finally
            {
                this.Close();
                ShowUserInfo(searchstate);
            }
        }