コード例 #1
0
        public static void create_Contain_In_DB(contain con)
        {
            SqlCommand c = new SqlCommand();

            c.CommandText = "EXECUTE dbo.SP_add_Contain @ProductName, @EdId, @Quantity,  @Description ";
            c.Parameters.AddWithValue("@ProductName", con.getProduct().getName());
            c.Parameters.AddWithValue("@EdId", con.getEquipmentDemand().getId());
            c.Parameters.AddWithValue("@Quantity", con.getQuantity());
            c.Parameters.AddWithValue("@Description", con.getDescription());
            Console.WriteLine(c.ToString());
            SQL_CON SC = new SQL_CON();

            SC.execute_non_query(c);
        }
コード例 #2
0
        public static void init_contain(int edId)
        { //מילוי המערך מתוך בסיס הנתונים
            SqlCommand c = new SqlCommand();

            c.CommandText = "EXECUTE dbo.Get_All_Contain " + edId;
            SQL_CON       SC  = new SQL_CON();
            SqlDataReader rdr = SC.execute_query(c);

            while (rdr.Read())
            {
                contain con = new contain(getEquipmentDemandObject(edId), getProductObject(rdr.GetValue(0).ToString()),
                                          int.Parse(rdr.GetValue(2).ToString()), rdr.GetValue(3).ToString());
                getEquipmentDemandObject(edId).addContain(con);
            }
        }
コード例 #3
0
        private void button1_Click(object sender, EventArgs e)

        {
            try
            {
                string reasonForDemand = ReasonForDemand.Text;
                if (string.IsNullOrWhiteSpace(reasonForDemand))
                {
                    throw new Exception("Reason for Demand is nesessary");
                }
                EquipmentDemand ed = new EquipmentDemand(Program.equipmentDemands.Count + 1, Program.empUser, DateTime.Now, reasonForDemand);
                Program.equipmentDemands.Add(ed);

                Program.create_EquipmentDemand_In_DB(ed);
                Program.empUser.addEquipmentDemand(ed);

                for (int rows = 0; rows < productList.Rows.Count; rows++)
                {
                    int    quantity    = 0;
                    string description = null;

                    if (productList.Rows[rows].Cells[1].Value != null)
                    {
                        int valueQuantity = int.Parse(productList.Rows[rows].Cells[1].Value.ToString());
                        if (valueQuantity != 0)
                        {
                            quantity = valueQuantity;
                        }
                        if (!string.IsNullOrWhiteSpace(productList.Rows[rows].Cells[2].Value.ToString()))
                        {
                            description = productList.Rows[rows].Cells[2].Value.ToString();
                        }
                        else
                        {
                            description = "N/A";
                        }
                        contain c = new contain(ed, Program.getProductObject(productList.Rows[rows].Cells[0].Value.ToString()), quantity, description);
                        ed.addContain(c);
                        Program.create_Contain_In_DB(c);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Invalid Input", MessageBoxButtons.OK);
            }
        }
コード例 #4
0
 public void addContain(contain c)
 {
     ContainsProducts.Add(c);
 }