Exemplo n.º 1
0
        public bool addToRepair(Buisness_Logic.repair rep)
        {
            bool temp = false;

            try
            {
                DataLayer.dbConnect con = new DataLayer.dbConnect();
                con.openConnection();

                string q = "Insert into tbl_repair (start_date,repairalble_itemID,equi_name) values (@sdate,@id,@name)";

                SqlCommand cmd = new SqlCommand(q, con.getConnection());

                cmd.Parameters.AddWithValue("@sdate", rep.start_date);
                cmd.Parameters.AddWithValue("@id", rep.equipmentID);
                cmd.Parameters.AddWithValue("@name", rep.equipmentName);

                cmd.ExecuteNonQuery();

                temp = true;
            }
            catch (Exception dfsd)
            {
                throw;
            }

            if (temp == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        private void btnupdate_i6_Click(object sender, EventArgs e)
        {
            try
            {
                Buisness_Logic.repair rep = new Buisness_Logic.repair();

                double cost_for_repair = string.IsNullOrWhiteSpace(txtI1_icost.Text) ? 0 : double.Parse(txtI1_icost.Text);
                rep.repID         = int.Parse(txtI1_irepair.Text);
                rep.equipmentID   = int.Parse(txtI1_icod.Text);
                rep.status        = cmbRepairINV.SelectedItem.ToString();
                rep.cost          = cost_for_repair;
                rep.descriptioin  = txtI1_idescription.Text;
                rep.start_date    = txtI1_istart.Text;
                rep.finished_date = txti_repfdate.Text;
                rep.equipmentName = txtI1_imachine.Text;

                if (rep.updateRepItemDetails(rep))
                {
                    MessageBox.Show("Record update successfull.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Record update failed.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception sdfas)
            {
                throw;
            }
        }
Exemplo n.º 3
0
        private void btnsearch_i5_Click(object sender, EventArgs e)
        {
            try
            {
                Buisness_Logic.repair rep = new Buisness_Logic.repair();

                bool x = rep.searchRepairItem((string.IsNullOrEmpty(txtI1_irepair.Text) ? 0 : int.Parse(txtI1_irepair.Text)), (string.IsNullOrEmpty(txtI1_icod.Text) ? 0 : int.Parse(txtI1_icod.Text)), rep);
                if (x)
                {
                    MessageBox.Show("Record found.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtI1_imachine.Text       = rep.equipmentName;
                    txtI1_irepair.Text        = rep.repID.ToString();
                    txtI1_icod.Text           = rep.equipmentID.ToString();
                    txtI1_istart.Text         = rep.start_date;
                    txtI1_idescription.Text   = rep.descriptioin;
                    txtI1_icost.Text          = rep.cost.ToString();
                    txti_repfdate.Text        = rep.finished_date;
                    cmbRepairINV.SelectedItem = rep.status;
                }
                else
                {
                    MessageBox.Show("No record found.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception sfsdf)
            {
                throw;
            }
        }
Exemplo n.º 4
0
        private void btnRepairs_addfrom_Click(object sender, EventArgs e)
        {
            DialogResult conform = MessageBox.Show("Are you sure you want add this item to repair?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (conform == DialogResult.Yes)
            {
                try
                {
                    Buisness_Logic.repair rep = new Buisness_Logic.repair();
                    rep.equipmentID   = int.Parse(txtEqui_code.Text);
                    rep.equipmentName = txtEqui_name.Text;
                    rep.start_date    = DateTime.Now.ToShortDateString();



                    if (rep.addToRepair(rep))
                    {
                        MessageBox.Show("Equipment is to be repaired.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Failed.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception repex)
                {
                    throw;
                }
            }
        }
Exemplo n.º 5
0
        public bool searchRepairItem(int repID, int equiID, Buisness_Logic.repair rep)
        {
            DataLayer.dbConnect con = new DataLayer.dbConnect();
            con.openConnection();
            bool temp = false;

            try
            {
                string q = "select * from tbl_repair where repairID=@rid or repairalble_itemID=@mid ";

                SqlCommand cmd = new SqlCommand(q, con.getConnection());

                cmd.Parameters.AddWithValue("@rid", repID);
                cmd.Parameters.AddWithValue("@mid", equiID);

                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable      dt = new DataTable();

                da.Fill(dt);

                if (dt.Rows.Count > 0)
                {
                    rep.repID        = (int)dt.Rows[0]["repairID"];
                    rep.equipmentID  = (int)dt.Rows[0]["repairalble_itemID"];
                    rep.status       = dt.Rows[0]["status"].ToString();
                    rep.descriptioin = dt.Rows[0]["description"].ToString();
                    if (!DBNull.Value.Equals(dt.Rows[0]["cost"]))
                    {
                        rep.cost = double.Parse(dt.Rows[0]["cost"].ToString());
                    }
                    else
                    {
                    }

                    rep.start_date    = dt.Rows[0]["start_date"].ToString();
                    rep.finished_date = dt.Rows[0]["finished_date"].ToString();
                    rep.equipmentName = dt.Rows[0]["equi_name"].ToString();

                    temp = true;
                }
            }
            catch (Exception fsdfs)
            {
                throw;
            }

            if (temp == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 6
0
        public bool updateRepItemDetails(Buisness_Logic.repair rep)
        {
            DataLayer.dbConnect con = new DataLayer.dbConnect();
            con.openConnection();
            bool temp = false;

            try
            {
                string qr = "update tbl_repair set status=@status,cost=@cost,description=@des,start_date=@sd,finished_date=@fd where repairID=@rid";


                SqlCommand cmd = new SqlCommand(qr, con.getConnection());
                cmd.Parameters.AddWithValue("@status", rep.status);
                cmd.Parameters.AddWithValue("@cost", rep.cost);
                cmd.Parameters.AddWithValue("@des", rep.descriptioin);
                cmd.Parameters.AddWithValue("@sd", rep.start_date);
                cmd.Parameters.AddWithValue("@fd", rep.finished_date);
                cmd.Parameters.AddWithValue("@rid", rep.repID);

                cmd.ExecuteNonQuery();
                temp = true;
            }
            catch (Exception fsd)
            {
                throw;
            }

            if (temp == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }