コード例 #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            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_vegetables(FruitName.Text, Convert.ToInt32(FrutCalorie.Text), FruitDesc.Text, "1", imgByteArr, Sec.Text, FoodChoice.SelectedIndex + 1);
                database.SaveChanges();
            }
            else
            {
                database.Sp_vegetables(FruitName.Text, Convert.ToInt32(FrutCalorie.Text), FruitDesc.Text, "1", null, Sec.Text, FoodChoice.SelectedIndex + 1);
            }
            database.SaveChanges();
        }
コード例 #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            bool Gender = true;


            if (MorabiZan.IsChecked == true)
            {
                Gender = false;
            }

            SHA256CryptoServiceProvider Sha2 = new SHA256CryptoServiceProvider();


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


            MorabiTable m = new MorabiTable();

            m.MorabiName     = MorabiName.Text;
            m.MorabiFamily   = MorabiFamily.Text;
            m.MorabiMeliCode = MorabiCodeMeli.Text;
            m.MorabiPhone    = MorabiPhone.Text;
            m.MorabiSen      = Convert.ToByte(MorabiSen.Text);
            m.MorabiUsername = UserName.Text;

            if (MorabiPassword.Text == MorabiPasswordRep.Text)

            {
                m.MorabiPassword = UserPasswordHashed;
            }

            else
            {
                MorabiPassword.Focus();
                MessageBox.Show("تکرار رمز عبور درست نمیباشد");
            }

            m.MorabiGender = Gender;
            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();
                m.MorabiImage = imgByteArr;
            }
            database.MorabiTable.Add(m);
            database.SaveChanges();
        }
コード例 #3
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            // insert to database FoodTemplates
            FoodTemplates F = new FoodTemplates()
            {
                Sobhane      = Sobhane_text.Text,
                Nahar        = Nahar_text.Text,
                Asrane       = Asrane_text.Text,
                Sham         = Sham_text.Text,
                AsraneDesc   = AsraneDesc.Text,
                SobhaneDesc  = SobhaneDesc.Text,
                NaharDesc    = NaharDesc.Text,
                ShamDesc     = ShamDesc.Text,
                AllCallory   = Convert.ToInt32(CaleryTotal.Content),
                TemplateName = NameFoods.Text,
                // VitaminUsed = Vitamins.Text
            };

            MessageBox.Show("برنامه غذایی ذخیره شد");
            database.FoodTemplates.Add(F);
            database.SaveChanges();
        }
コード例 #4
0
        private void newuser_Click(object sender, RoutedEventArgs e)
        {
            string    time = DateTime.Now.ToString("HH:mm");
            Inv       U    = new Inv();
            SucFul    S    = new SucFul();
            ErrorPage E    = new ErrorPage();


            string ClosedID = Txt_Komod.Text.ToString();


            try
            {
                U.UserID       = Convert.ToInt16(txt_id.Text);
                U.InvEnterDate = time;
                U.InvOutDate   = "1";
                if (Txt_Komod.Text.Trim() != "")
                {
                    U.InvCount = Convert.ToInt32(Txt_Komod.Text);
                }
                else if (Txt_Komod.Text.Trim() == "")
                {
                    U.InvCount = 1;
                }
                U.InvDate = String.Format("{0:yyyy/MM/dd}", Convert.ToDateTime(EnterDate.Text));



                database.Inv.Add(U);
                database.SaveChanges();



                ShowUserInfo(searchstate);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.ToString());
            }
            finally
            {
                txt_id.Focus();
                txt_id.Text    = "";
                Txt_Komod.Text = "";
            }
        }
コード例 #5
0
        private void RadButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                System.Windows.Forms.DialogResult dialogResult = System.Windows.Forms.MessageBox.Show(" آیا میخواهید " + Harekat_lbl.Text + " به حرکات شما اضافه شود ؟ ", "اطلاعیه", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);

                if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                {
                    database.Moving(0, Harekat_lbl.Text);
                    database.SaveChanges();
                    ShowUserInfo(searchstate);
                }
            }
            catch
            {
                MessageBox.Show("error");
            }
        }
コード例 #6
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                MorabiTable m = database.MorabiTable.First(c => c.MorabiID == ID);
                m.MorabiName     = MorabiName.Text;
                m.MorabiFamily   = MorabiFamily.Text;
                m.MorabiMeliCode = MorabiCodeMeli.Text;
                m.MorabiPhone    = MorabiPhone.Text;
                m.MorabiSen      = Convert.ToByte(MorabiSen.Text);

                database.SaveChanges();
                MessageBox.Show("اطلاعات با موفقیت بروزرسانی شد.");
            }
            catch
            {
                MessageBox.Show("در به روز رسانی اطلاعات مشکلی به وجود آمد.");
            }
        }
コード例 #7
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (OldPassword.Password == passwordfind)
            {
                if (Password.Password == PasswordRetry.Password)
                {
                    MorabiTable m = database.MorabiTable.First(c => c.MorabiID == ID);
                    m.MorabiPassword = Password.Password;
                    database.SaveChanges();
                    MessageBox.Show("اطلاعات با موفقیت بروزرسانی شد.");
                }
                else
                {
                    MessageBox.Show("در به روز رسانی اطلاعات مشکلی به وجود آمد.");
                }
            }


            else
            {
                MessageBox.Show("پسورد قدیمی اشتباه است");
            }
        }
コード例 #8
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();
            }
        }
コード例 #9
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.MemberStartDate  = String.Format("{0:yyyy/MM/dd}", Convert.ToDateTime(MahView.Text));
                U.MemberLastCharge = String.Format("{0:yyyy/MM/dd}", Convert.ToDateTime(TaView.Text));
                TimeOutSubmit      = String.Format("{0:yyyy/MM/dd}", Convert.ToDateTime(TaView.Text));
                U.MemberMounth     = Convert.ToByte(mahv);
                U.MemberMountTwo   = Convert.ToByte(newdate);

                U.MemberCharge   = Convert.ToDecimal(UserCharge.Text.Trim());
                U.UserBedehiRial = Convert.ToDecimal(BedehiText.Text.Trim()) == 50 ? 0 : Convert.ToDecimal(BedehiText.Text.Trim());
                U.BedehKariDesc  = BedehiDescText.Text == "توضیحات وجود ندارد." ? "شارژ و تمدید حساب" : BedehiDescText.Text.Trim();
                U.MemberService  = Convert.ToByte(bedehs);



                database.Members.Add(U);
                database.SaveChanges();
                MessageBox.Show("ثبت شد");
            }
            catch
            {
                MessageBox.Show("مشکلی در ثبت اطلاعات به وجود امده است");
            }
            finally
            {
                this.Close();
            }


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



            SqlConnection con1 = new SqlConnection(PublicVar.ConnectionString);

            con1.Open();
            SqlCommand Commandcmdsz   = new SqlCommand("update VW_TimeOut set UserActive = 1 Where UserFindID = " + memberid, con1);
            SqlCommand Commandcmdszz  = new SqlCommand("update VW_TimeOut set  UserEndDate = '" + TimeOutSubmit + "' where UserFindID = " + memberid, con1);
            SqlCommand Commandcmdszzz = new SqlCommand("update Users set  UserEstakhr = " + estakhr + " , UserBime = " + bime + "," +
                                                       " UserKhososi = " + khososi + " , UserBarnameQazaiy = " + barnameqazaiy + " Where UserID = " + memberid, con1);


            Commandcmdsz.ExecuteScalar();
            Commandcmdszz.ExecuteScalar();
            Commandcmdszzz.ExecuteScalar();
            con1.Close();
        }
コード例 #10
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);
            }
        }