Beispiel #1
0
 public contain(EquipmentDemand equipmentDemand, Product product, int quantity, string description)
 {
     this.equipmentDemand = equipmentDemand;
     this.product         = product;
     this.quantity        = quantity;
     this.description     = description;
 }
        public static void update_ed_approvalNote_in_DB(EquipmentDemand ed, String status)
        {
            SqlCommand c = new SqlCommand();

            c.CommandText = "EXECUTE dbo.SP_update_EquipmentDemand_ApprovalNote @EquipmentDemand, @ApprovalNote";
            c.Parameters.AddWithValue("@EquipmentDemand", ed.getId());
            c.Parameters.AddWithValue("@ApprovalNote", ed.getApprovalNote());
            Console.WriteLine(c.ToString());
            SQL_CON SC = new SQL_CON();

            SC.execute_non_query(c);
        }
        public static EquipmentDemand getEquipmentDemandObject(int id)
        {
            EquipmentDemand edRes = null;

            foreach (EquipmentDemand ed in equipmentDemands)
            {
                if (ed.getId() == id)
                {
                    edRes = ed;
                }
            }

            return(edRes);
        }
        public static void create_EquipmentDemand_In_DB(EquipmentDemand ed)
        {
            SqlCommand c = new SqlCommand();

            c.CommandText = "EXECUTE dbo.SP_add_EquipmentDemand @id, @Emp, @reason";
            c.Parameters.AddWithValue("@id", ed.getId());
            if (ed.getCreator() != null)
            {
                c.Parameters.AddWithValue("@Emp", ed.getCreator().getId());
            }
            c.Parameters.AddWithValue("@reason", ed.getReason());
            Console.WriteLine(c.ToString());
            SQL_CON SC = new SQL_CON();

            SC.execute_non_query(c);
        }
        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);
            }
        }
        public static void init_EquipmentDemands()
        { //מילוי המערך מתוך בסיס הנתונים
            SqlCommand c = new SqlCommand();

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

            equipmentDemands = new List <EquipmentDemand>();

            while (rdr.Read())
            {
                EquipmentDemand ed = new EquipmentDemand(int.Parse(rdr.GetValue(0).ToString()), getEmployeeObject(rdr.GetValue(1).ToString()), DateTime.Parse((rdr.GetValue(5).ToString())), rdr.GetValue(2).ToString());
                equipmentDemands.Add(ed);
                init_contain(ed.getId());
                ed.setStatus(rdr.GetValue(3).ToString());
                ed.addApprovalNote(rdr.GetValue(4).ToString());
                ed.getCreator().addEquipmentDemand(ed);
            }
        }
Beispiel #7
0
        private void Submit_ED_Approval_Click(object sender, EventArgs e)
        {
            for (int rows = 0; rows < OpenEDforLC.Rows.Count; rows++)
            {
                if (OpenEDforLC.Rows[rows].Cells[5].Value != null && OpenEDforLC.Rows[rows].Cells[6].Value != null)
                {
                    MessageBox.Show("Please make sure you are marking only one option", "Message", MessageBoxButtons.OK);
                }
                else if (OpenEDforLC.Rows[rows].Cells[5].Value == null && OpenEDforLC.Rows[rows].Cells[6].Value == null)
                {
                    continue;
                }
                else
                {
                    String newStatus    = "Not Handeled";
                    String approvalNote = null;
                    if (OpenEDforLC.Rows[rows].Cells[7].Value != null)
                    {
                        approvalNote = OpenEDforLC.Rows[rows].Cells[7].Value.ToString();
                    }

                    EquipmentDemand ed = Program.getEquipmentDemandObject(int.Parse(OpenEDforLC.Rows[rows].Cells[0].Value.ToString()));
                    if (OpenEDforLC.Rows[rows].Cells[5].Value != null)
                    {
                        ed.approved();
                        newStatus = "Approved";
                    }
                    if (OpenEDforLC.Rows[rows].Cells[6].Value != null)
                    {
                        ed.notApproved();
                        newStatus = "Not Approved";
                    }
                    if (approvalNote != null)
                    {
                        ed.addApprovalNote(approvalNote);
                        Program.update_ed_approvalNote_in_DB(ed, approvalNote);
                    }
                    Program.update_ed_status_in_DB(ed, newStatus);
                }
            }
        }
 public void addEquipmentDemand(EquipmentDemand ed)
 {
     createdEquipmentDemands.Add(ed);
 }