コード例 #1
0
ファイル: Details.cs プロジェクト: Natishlom/EasyToSit
        private void CreatSapak(TextBox t)
        {
            Sapak  sapak = new Sapak();
            string s     = t.Name.Substring(3);


            foreach (Label lbl in sapakimlbl)
            {
                if (lbl.Name.Equals("lbl" + s))
                {
                    sapak.Name = lbl.Text;
                    break;
                }
            }
            sapak.Price = Int32.Parse(t.Text);
            sapak.Id    = sapakId;
            sapakId++;
            sapakim.Add(sapak);
            try
            {
                con = new SqlConnection(conString);
                con.Open();
                cmd = new SqlCommand("INSERT INTO EasySapakimData (id,name,price) VALUES ('" + sapak.Id + "','" + sapak.Name + "','" + sapak.Price + "')", con);
                cmd.ExecuteNonQuery();
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
コード例 #2
0
ファイル: Details.cs プロジェクト: Natishlom/EasyToSit
        private void btnSave_Click(object sender, EventArgs e)
        {
            try {
                con = new SqlConnection(conString);
                con.Open();
                cmd = new SqlCommand("DELETE EasySapakimData", con);
                cmd.ExecuteNonQuery();
                con.Close();
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            textTakin();
            sapakim          = new List <Sapak>();
            txtExpenses.Text = SumOfExpenses();
            if (txtExpenses.Text.Length == 0)
            {
                txtExpenses.Text = "0";
            }
            if (txtRevenue.Text.Length == 0)
            {
                txtRevenue.Text = "0";
            }
            txtProfitOrLoss.Text = (Int32.Parse(txtRevenue.Text) - Int32.Parse(txtExpenses.Text)).ToString();
            if ((Int32.Parse(txtRevenue.Text) - Int32.Parse(txtExpenses.Text)) < 0)
            {
                lblProfitOrLoss.Text = "הפסד";
            }
            else
            if ((Int32.Parse(txtRevenue.Text) - Int32.Parse(txtExpenses.Text)) > 0)
            {
                lblProfitOrLoss.Text = "רווח";
            }
            else
            {
                lblProfitOrLoss.Text = "רווח/הפסד";
            }
            int price;

            if (txtDose.Text.Equals(""))
            {
                price = 0;
            }
            else
            {
                price = Int32.Parse(txtDose.Text);
            }

            Sapak s = new Sapak(sapakId, "מחיר מנה", price);

            sapakId++;
            sapakim.Add(s);
            try
            {
                con = new SqlConnection(conString);
                con.Open();
                cmd = new SqlCommand("INSERT INTO EasySapakimData (id,name,price) VALUES ('" + s.Id + "','" + s.Name + "','" + s.Price + "')", con);
                cmd.ExecuteNonQuery();
                con.Close();
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #3
0
ファイル: Details.cs プロジェクト: Natishlom/EasyToSit
        private void Details_Load(object sender, EventArgs e)
        {
            int    guset = 0, gifts = 0;
            string countGuest, strGift;


            txtUserName.Text       = userName.NameHusband + " ו" + userName.NameWife + " " + userName.LaseName;
            cboTaype.SelectedIndex = cboTaype.FindString(userName.TaypeEvent);
            txtDate.Text           = userName.DateEvent.Date.ToString("MM/dd/yyyy");
            txtNameHall.Text       = userName.NameHall;
            sapakim = new List <Sapak>();
            using (SqlConnection con = new SqlConnection(conString))
            {
                con.Open();
                try
                {
                    using (SqlCommand cmd = new SqlCommand("SELECT * FROM EasySapakimData", con))
                    {
                        using (IDataReader dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                Sapak s = new Sapak();
                                s.Id    = dr.GetInt32(0);
                                s.Name  = dr.GetString(1);
                                s.Price = dr.GetInt32(2);
                                sapakim.Add(s);
                            }
                        }


                        try
                        {
                            SqlCommand  cm = new SqlCommand("SELECT Count,Gift FROM EasyGusetData", con);
                            IDataReader rd = cm.ExecuteReader();
                            while (rd.Read())
                            {
                                guset += rd.GetInt32(0);
                                gifts += rd.GetInt32(1);
                            }
                            countGuest = returnNumber(guset);
                            strGift    = returnNumber(gifts);

                            txtRevenue.Text      = strGift;
                            txtCountOfGuest.Text = countGuest;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message + Environment.NewLine + "לא הוכנסו במסך קליטת אורחים נתונים.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            throw;
                        }
                    }
                    con.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                foreach (Sapak s in sapakim)
                {
                    switch (s.Id)
                    {
                    case 1:
                    {
                        txtLighting.Text = returnNumber(s.Price);
                    }
                    break;

                    case 2:
                    {
                        txtDesign.Text = returnNumber(s.Price);
                    }
                    break;

                    case 3:
                    {
                        txtPhotography.Text = returnNumber(s.Price);
                    }
                    break;

                    case 4:
                    {
                        txtDj.Text = returnNumber(s.Price);
                    }
                    break;

                    case 5:
                    {
                        txtBar.Text = returnNumber(s.Price);
                    }
                    break;

                    case 6:
                    {
                        txtSpak1.Text = returnNumber(s.Price);
                        lblSpak1.Text = s.Name;
                    }
                    break;

                    case 7:
                    {
                        txtSpak2.Text = returnNumber(s.Price);
                        lblSpak2.Text = s.Name;
                    }
                    break;

                    case 8:
                    {
                        txtSpak3.Text = returnNumber(s.Price);
                        lblSpak3.Text = s.Name;
                    }
                    break;

                    case 9:
                    {
                        txtSpak4.Text = returnNumber(s.Price);
                        lblSpak4.Text = s.Name;
                    }
                    break;

                    case 10:
                    {
                        txtSpak5.Text = returnNumber(s.Price);
                        lblSpak5.Text = s.Name;
                    }
                    break;

                    case 11:
                    {
                        txtSpak6.Text = returnNumber(s.Price);
                        lblSpak6.Text = s.Name;
                    }
                    break;

                    case 12:
                    {
                        txtSpak7.Text = returnNumber(s.Price);
                        lblSpak7.Text = s.Name;
                    }
                    break;

                    case 13:
                    {
                        txtSpak8.Text = returnNumber(s.Price);
                        lblSpak8.Text = s.Name;
                    }
                    break;

                    case 14:
                    {
                        txtSpak9.Text = returnNumber(s.Price);
                        lblSpak9.Text = s.Name;
                    }
                    break;

                    case 15:
                    {
                        txtSpak10.Text = returnNumber(s.Price);
                        lblSpak10.Text = s.Name;
                    }
                    break;

                    case 16:
                    {
                        txtDose.Text = returnNumber(s.Price);
                    }
                    break;

                    default: continue;
                    }
                }
            }
        }