public bool save_Product(product prod)
        {
            bool temp1 = false;

            try
            {
                // Initialize image

                DataLayer.dbConnect dbp = new DataLayer.dbConnect();
                dbp.openConnection();
                string query1 = "INSERT INTO tbl_product (name,make ,p_type, qty,buying_price,selling_price,photo) VALUES  (@name, @make, @type, @qty,@bprice,@sprice, @photo)";

                SqlCommand cmd = new SqlCommand(query1, dbp.getConnection());
                cmd.Parameters.AddWithValue("@name", prod.name);
                cmd.Parameters.AddWithValue("@make", prod.make);
                cmd.Parameters.AddWithValue("@type", prod.productType);
                cmd.Parameters.AddWithValue("@qty", prod.qty);
                cmd.Parameters.AddWithValue("@bprice", prod.buying_price);
                cmd.Parameters.AddWithValue("@sprice", prod.selling_Price);
                cmd.Parameters.AddWithValue("@photo", prod.photo);


                cmd.ExecuteNonQuery();

                string q2 = "SELECT productID from tbl_product where name=@name ";

                SqlCommand cmd2 = new SqlCommand(q2, dbp.getConnection());

                cmd2.Parameters.AddWithValue("@name", prod.name);

                SqlDataReader dr = cmd2.ExecuteReader();



                while (dr.Read())
                {
                    prod.productID = (int)dr["productID"];
                }

                dr.Close();
                dbp.closeConnection();
                temp1 = true;
            }
            catch (Exception exprep)
            {
                MessageBox.Show(exprep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }

            if (temp1 == true)
            {
                return(true);
            }

            else
            {
                return(false);
            }
        }
        public bool updateOtherMembers(AreobicMember arem)
        {
            bool temp = false;

            DataLayer.dbConnect con = new DataLayer.dbConnect();
            con.openConnection();
            SqlTransaction trn = con.getConnection().BeginTransaction();

            try
            {
                //qery one
                string q1 = "update tbl_member set name=@name, dob=@dob,address=@address,nic=@nic,gender=@gender,phone=@phone where regNo=@regNo";

                SqlCommand cmd1 = new SqlCommand(q1, con.getConnection());

                cmd1.Parameters.AddWithValue("@regNo", arem.MemberID);
                cmd1.Parameters.AddWithValue("@name", arem.name);
                cmd1.Parameters.AddWithValue("@dob", arem.dob);
                cmd1.Parameters.AddWithValue("@address", arem.addresss);
                cmd1.Parameters.AddWithValue("@nic", arem.nic);
                cmd1.Parameters.AddWithValue("@gender", arem.gender);
                cmd1.Parameters.AddWithValue("@phone", arem.phone);


                cmd1.Transaction = trn;
                cmd1.ExecuteNonQuery();

                //qery two
                string q2 = "update tbl_areobic_member set  service_type=@st where memberID=@regNo";

                SqlCommand cmd2 = new SqlCommand(q2, con.getConnection());

                cmd2.Parameters.AddWithValue("@regNo", arem.MemberID);
                cmd2.Parameters.AddWithValue("@st", arem.service_type);

                cmd2.Transaction = trn;

                cmd2.ExecuteNonQuery();
                trn.Commit();
                con.closeConnection();

                temp = true;
            }
            catch (Exception dd)
            {
                trn.Rollback();
                throw;
            }

            if (temp == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #3
0
        public bool updateWeightLiftingItems(Buisness_Logic.nonRepairable_Item prd)
        {
            DataLayer.dbConnect con = new DataLayer.dbConnect();
            con.openConnection();

            bool           temp = false;
            SqlTransaction trn  = con.getConnection().BeginTransaction();

            try
            {
                string qry1 = "update tbl_inventory set name=@name,make=@make,model=@model,price=@price,photo=@photo where invID=@id";

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

                cmd.Parameters.AddWithValue("@name", prd.name);
                cmd.Parameters.AddWithValue("@make", prd.make);
                cmd.Parameters.AddWithValue("@model", prd.model);
                cmd.Parameters.AddWithValue("@price", prd.price);
                cmd.Parameters.AddWithValue("@photo", prd.photo);
                cmd.Parameters.AddWithValue("@id", prd.invID);

                cmd.Transaction = trn;
                cmd.ExecuteNonQuery();

                string qry2 = "update tbl_non_repairable set qty=@qty,weight=@weight where invetoryID=@invid";

                SqlCommand cmd2 = new SqlCommand(qry2, con.getConnection());

                cmd2.Parameters.AddWithValue("@weight", prd.weight);
                cmd2.Parameters.AddWithValue("@qty", prd.qty);
                cmd2.Parameters.AddWithValue("@invid", prd.invID);
                cmd2.Transaction = trn;
                cmd2.ExecuteNonQuery();

                trn.Commit();
                temp = true;

                con.closeConnection();
            }
            catch (Exception dsa)
            {
                trn.Rollback();
                throw;
            }

            if (temp == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #4
0
        private void gdgfdgaetg_Click(object sender, EventArgs e)
        {
            if (validate_sales())
            {
                try
                {
                    int    year  = int.Parse(txtsalesyear.Text);
                    string month = cmbFin2_month.SelectedItem.ToString();
                    double incm  = double.Parse(txtFin2_income.Text);
                    double rev   = double.Parse(txtFin2_revenue.Text);
                    double expen = double.Parse(txtFin2_expense.Text);
                    string q     = "insert into sales_finance values(@y,@m,@a,@e,@r)";

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

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

                    cmd.Parameters.AddWithValue("@y", year);
                    cmd.Parameters.AddWithValue("@m", month);
                    cmd.Parameters.AddWithValue("@a", incm);
                    cmd.Parameters.AddWithValue("@e", expen);
                    cmd.Parameters.AddWithValue("@r", rev);

                    cmd.ExecuteNonQuery();


                    MessageBox.Show("Succesfull", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception fdf)
                {
                    throw;
                }
            }
        }
Exemple #5
0
        private void btnFitness_savetodb_Click(object sender, EventArgs e)
        {
            if (validatefitness_Year())
            {
                try
                {
                    int    year   = int.Parse(txtFin_fitYear.Text);
                    string month  = cmbFin1_month.SelectedItem.ToString();
                    double amount = double.Parse(txtFin1_income.Text);
                    string q      = "insert into gym_income values(@y,@m,@a)";

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

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

                    cmd.Parameters.AddWithValue("@y", year);
                    cmd.Parameters.AddWithValue("@m", month);
                    cmd.Parameters.AddWithValue("@a", amount);

                    cmd.ExecuteNonQuery();


                    MessageBox.Show("Succesfull", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception fdf)
                {
                    throw;
                }
            }
        }
        public DataTable editGymMembers()
        {
            try
            {
                DataLayer.dbConnect condg = new DataLayer.dbConnect();
                condg.openConnection();

                string qdg1 = "select m.regNo as 'MemberID' , m.name as 'Name' , m.dob as 'DOB' , m.address as 'Address' ,"
                              + " m.nic as 'NIC' , m.gender as 'Gender' , m.phone as 'Phone' , g.email as 'E-mail', "
                              + "g.joined_date as 'Joined Date' , g.BMI , g.height as 'Height' , g.weight as 'Weight' , "
                              + " g.payment_plan as 'Payment Plan' , g.fat_level as 'Fat Level', g.photo as 'p' FROM tbl_member m ,tbl_gymMember g "
                              + "WHERE m.regNo=g.memberID";


                SqlCommand cmddg1 = new SqlCommand(qdg1, condg.getConnection());

                SqlDataAdapter dadg1 = new SqlDataAdapter(cmddg1);
                DataTable      dtdg1 = new DataTable();

                dadg1.Fill(dtdg1);

                return(dtdg1);
            }
            catch (Exception el)
            {
                throw;
            }
        }
Exemple #7
0
        private void database_refresh()
        {
            DataLayer.dbConnect con = new DataLayer.dbConnect();
            con.openConnection();

            string q1 = "select * from tbl_exercise";

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

            DataTable      dtq = new DataTable();
            SqlDataAdapter da1 = new SqlDataAdapter(cmd);

            comboW5_name.Refresh();
            da1.Fill(dtq);

            if (dtq.Rows.Count > 0)
            {
                for (int i = 0; i < dtq.Rows.Count; i++)
                {
                    comboW5_name.Items.Add(dtq.Rows[i]["name"].ToString());
                }
            }


            // for dataGridView
            dataGrid_exercise.DataSource = dtq;
            this.dataGrid_exercise.Columns[1].Visible = false;
            con.closeConnection();
        }
Exemple #8
0
        public DataTable search_aerobic_fee(int memberID, string nic)
        {
            DataTable dt = new DataTable();

            try
            {
                DataLayer.dbConnect con = new DataLayer.dbConnect();
                con.openConnection();
                string     q   = "select * from view_aerobic_mem_Fee where memberID=@mid or nic=@nic";
                SqlCommand cmd = new SqlCommand(q, con.getConnection());

                cmd.Parameters.AddWithValue("@mid", memberID);
                cmd.Parameters.AddWithValue("@nic", nic);
                SqlDataAdapter da = new SqlDataAdapter(cmd);

                da.Fill(dt);
            }

            catch (Exception ffg)
            {
                throw;
            }

            return(dt);
        }
Exemple #9
0
        private void btnFin3_check_Click(object sender, EventArgs e)
        {
            if (validate_os())
            {
                try
                {
                    int    year  = int.Parse(txtos_year.Text);
                    string month = cmbFin3Month.SelectedItem.ToString();
                    double incm  = double.Parse(txtFin3_income.Text);
                    string type  = cmbFin3_serviceType.SelectedItem.ToString();
                    string q     = "insert into other_sevieces_income values(@y,@m,@a,@p)";

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

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

                    cmd.Parameters.AddWithValue("@y", year);
                    cmd.Parameters.AddWithValue("@m", month);
                    cmd.Parameters.AddWithValue("@a", incm);
                    cmd.Parameters.AddWithValue("@p", incm);


                    cmd.ExecuteNonQuery();


                    MessageBox.Show("Succesfull", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception fdf)
                {
                    throw;
                }
            }
        }
        public bool deleteProduct(int id)
        {
            bool temp = false;

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

            try
            {
                string qd = "delete tbl_product where productID=@id";

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

                cmd.Parameters.AddWithValue("@id", id);

                cmd.ExecuteNonQuery();

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

            if (temp == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #11
0
        public DataTable searchEqui_Items()
        {
            // Buisness_Logic.product prd = new Buisness_Logic.product();

            bool temp = false;

            DataLayer.dbConnect con = new DataLayer.dbConnect();
            con.openConnection();
            DataTable dt = new DataTable();

            try
            {
                string qr = "select * from view_repairItemsSet";

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



                SqlDataAdapter da = new SqlDataAdapter(cmd);


                da.Fill(dt);
            }
            catch (Exception pt)
            {
                throw;
            }

            return(dt);
        }
        public DataTable searchEMP_for_datagrid()
        {
            DataTable dtq = new DataTable();

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

                string query1 = "SELECT * FROM tbl_employee ";

                SqlCommand cmd1 = new SqlCommand(query1, dbemp_seach.getConnection());



                SqlDataAdapter da1 = new SqlDataAdapter(cmd1);

                da1.Fill(dtq);
            }
            catch (Exception ert)
            {
                throw;
            }
            return(dtq);
        }
Exemple #13
0
        public DataTable getPaymentPendingList()
        {
            try
            {
                DataLayer.dbConnect conrep1 = new DataLayer.dbConnect();
                conrep1.openConnection();

                string qrep1 = "SELECT * FROM vw_paymentPending";

                SqlCommand cmdrep1 = new SqlCommand(qrep1, conrep1.getConnection());

                SqlDataAdapter darep1 = new SqlDataAdapter(cmdrep1);


                DataTable dtrep1 = new DataTable();

                darep1.Fill(dtrep1);

                return(dtrep1);
            }
            catch (Exception erep)
            {
                throw;
            }
        }
        public bool addOtherMembers_Exist(Buisness_Logic.AreobicMember am)
        {
            DataLayer.dbConnect con = new DataLayer.dbConnect();
            con.openConnection();

            bool temp1 = false;

            try
            {
                string q2 = "INSERT INTO tbl_areobic_member VALUES (@memid, @stype)";

                SqlCommand cmd2 = new SqlCommand(q2, con.getConnection());

                cmd2.Parameters.AddWithValue("@memid", am.MemberID);
                cmd2.Parameters.AddWithValue("@stype", am.service_type);

                cmd2.ExecuteNonQuery();


                temp1 = true;
            }
            catch (Exception exareo1)
            {
                throw;
            }

            if (temp1 == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #15
0
        private void btnFin5_Add_Click(object sender, EventArgs e)
        {
            if (validate_expenxe())
            {
                try
                {
                    string date   = dateTimePickerMem.Value.ToString();
                    string name   = cmbFin5_expenseType.SelectedItem.ToString();
                    double amount = double.Parse(txtFin5_amount.Text);


                    string q = "insert into tbl_expences (name,date,amount) values(@n,@d,@a)";

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

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

                    cmd.Parameters.AddWithValue("@d", date);
                    cmd.Parameters.AddWithValue("@a", amount);
                    cmd.Parameters.AddWithValue("@n", name);


                    cmd.ExecuteNonQuery();


                    MessageBox.Show("Succesfull", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception fdf)
                {
                    throw;
                }
            }
        }
Exemple #16
0
        public DataTable searchWorkouts_for_report(string name)
        {
            DataTable dtq = new DataTable();

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

                string query1 = "SELECT * FROM tbl_workout WHERE w_name=@workout ";

                SqlCommand cmd1 = new SqlCommand(query1, workoutSearch.getConnection());
                cmd1.Parameters.AddWithValue("@workout", name);


                SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
                //  workout wrk = new workout();
                da1.Fill(dtq);


                workoutSearch.closeConnection();
            }
            catch (Exception exp)
            {
                throw;
            }

            return(dtq);
        }
Exemple #17
0
        public DataTable getExercises_from_workoutGrid(string wn)
        {
            DataTable dtq = new DataTable();

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

                string query1 = "SELECT * FROM tbl_workout_exercise where w_name=@wn ";

                SqlCommand cmd1 = new SqlCommand(query1, workoutSearch.getConnection());

                cmd1.Parameters.AddWithValue("@wn", wn);



                SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
                //  workout wrk = new workout();
                da1.Fill(dtq);


                workoutSearch.closeConnection();
            }
            catch (Exception exp)
            {
                throw;
            }

            return(dtq);
        }
Exemple #18
0
        public DataTable searchWorkouts_for_grid()
        {
            DataTable dtq = new DataTable();

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

                string query1 = "SELECT * FROM tbl_workout ";

                SqlCommand cmd1 = new SqlCommand(query1, workoutSearch.getConnection());



                SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
                //  workout wrk = new workout();
                da1.Fill(dtq);


                workoutSearch.closeConnection();
            }
            catch (Exception exp)
            {
                throw;
            }

            return(dtq);
        }
Exemple #19
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);
            }
        }
Exemple #20
0
        public bool addFee(fee f, gymMember g)
        {
            try
            {
                paymentCalculation(f, g);


                DataLayer.dbConnect dbfee = new DataLayer.dbConnect();
                dbfee.openConnection();

                string qf1 = "insert into tbl_fee (amount,service,valde_date,paid_date,paid_time,memberID) values(@amount,@service,@valid_date,@paid_date,@paidTime,@memerID)";

                SqlCommand cmd1 = new SqlCommand(qf1, dbfee.getConnection());


                cmd1.Parameters.AddWithValue("@amount", f.newAmount);
                cmd1.Parameters.AddWithValue("@service", f.service);
                cmd1.Parameters.AddWithValue("@valid_date", f.PaymentvalidDate);
                cmd1.Parameters.AddWithValue("@paid_date", f.paidDate);
                cmd1.Parameters.AddWithValue("@memerID", f.memberID);
                cmd1.Parameters.AddWithValue("@paidTime", f.paidTime);


                cmd1.ExecuteNonQuery();
                return(true);
            }
            catch (Exception ext)
            {
                MessageBox.Show(ext.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
        public bool deleteMemeber(gymMember gm)
        {
            bool tempdel = false;

            DataLayer.dbConnect cond = new DataLayer.dbConnect();
            cond.openConnection();
            SqlTransaction trnd = cond.getConnection().BeginTransaction();

            try
            {
                string qd = "DELETE tbl_gymMember WHERE memberID=@mem ";

                SqlCommand cmdel = new SqlCommand(qd, cond.getConnection());

                cmdel.Parameters.AddWithValue("@mem", gm.MemberID);
                cmdel.Transaction = trnd;

                cmdel.ExecuteNonQuery();


                string qd1 = "DELETE tbl_member WHERE regNo=@mem ";

                SqlCommand cmdel1 = new SqlCommand(qd1, cond.getConnection());

                cmdel1.Parameters.AddWithValue("@mem", gm.MemberID);
                cmdel1.Transaction = trnd;
                cmdel1.ExecuteNonQuery();
                trnd.Commit();
                cond.closeConnection();

                tempdel = true;
            }
            catch (Exception edel)
            {
                trnd.Rollback();
                throw;
            }

            if (tempdel == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #22
0
        public bool deleteWLI(int id)
        {
            bool temp = false;

            DataLayer.dbConnect con = new DataLayer.dbConnect();
            con.openConnection();
            SqlTransaction trn = con.getConnection().BeginTransaction();

            try
            {
                string qd = "delete tbl_non_repairable where invetoryID=@id";

                SqlCommand cmd1 = new SqlCommand(qd, con.getConnection());

                cmd1.Parameters.AddWithValue("@id", id);
                cmd1.Transaction = trn;
                cmd1.ExecuteNonQuery();


                string q2 = "delete tbl_inventory where invID=@id";

                SqlCommand cmd2 = new SqlCommand(q2, con.getConnection());

                cmd2.Parameters.AddWithValue("@id", id);
                cmd2.Transaction = trn;
                cmd2.ExecuteNonQuery();

                trn.Commit();
                con.closeConnection();
                temp = true;
            }
            catch (Exception ui)
            {
                trn.Rollback();
                throw;
            }

            if (temp == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #23
0
        public bool calculate_salaryl(int month, int year, int empid, salary sq)
        {
            bool t1 = false;

            try
            {
                double total_hours, total_extraHours;
                double rate_h, rate_extra;
                double s1, s2, salary;
                DataLayer.dbConnect con = new DataLayer.dbConnect();
                con.openConnection();

                string q = "select sum(hours_worked) as 'h' , sum(extra_hours) as 'e' from tbl_emp_attendence where datepart(yy,theDay)=@y and DATEPART(mm,theDay)=@m";

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

                cmd.Parameters.AddWithValue("@y", year);
                cmd.Parameters.AddWithValue("@m", year);


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

                da.Fill(dt);
                rate_extra = 200.00;
                rate_h     = 150.00;



                if (dt.Rows.Count == 1)
                {
                    total_hours      = (double)dt.Rows[0]["h"];
                    total_extraHours = (double)dt.Rows[0]["e"];

                    s1 = total_hours * rate_h;
                    s2 = total_extraHours * rate_extra;

                    salary          = s1 + s2;
                    t1              = true;
                    sq.ot           = s2;
                    sq.originalsala = s2;
                    sq.tot_hours    = total_hours;
                    sq.extr_hours   = total_extraHours;
                }
            }
            catch (Exception gfg)
            {
                throw;
            }
            if (t1 == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public bool searchEMP(Buisness_Logic.employee emp)
        {
            try
            {
                DataLayer.dbConnect dbemp_seach = new DataLayer.dbConnect();
                dbemp_seach.openConnection();
                bool   temp   = false;
                string query1 = "SELECT * FROM tbl_employee WHERE empID=@reg OR name=@name OR nic=@nic";

                SqlCommand cmd1 = new SqlCommand(query1, dbemp_seach.getConnection());

                cmd1.Parameters.AddWithValue("@reg", emp.empID);
                cmd1.Parameters.AddWithValue("@name", emp.name);
                cmd1.Parameters.AddWithValue("@nic", emp.nic);


                DataTable      dtq = new DataTable();
                SqlDataAdapter da1 = new SqlDataAdapter(cmd1);

                da1.Fill(dtq);

                if (dtq.Rows.Count > 0)
                {
                    emp.empID      = int.Parse(dtq.Rows[0]["empID"].ToString());
                    emp.name       = dtq.Rows[0]["name"].ToString();
                    emp.nic        = dtq.Rows[0]["nic"].ToString();
                    emp.dob        = dtq.Rows[0]["dob"].ToString();
                    emp.gender     = dtq.Rows[0]["gender"].ToString();
                    emp.address    = dtq.Rows[0]["address"].ToString();
                    emp.phone      = dtq.Rows[0]["phone"].ToString();
                    emp.email      = dtq.Rows[0]["email"].ToString();
                    emp.position   = dtq.Rows[0]["position"].ToString();
                    emp.profile    = dtq.Rows[0]["profile"].ToString();
                    emp.photo      = (byte[])dtq.Rows[0]["photo"];
                    emp.joinedDate = dtq.Rows[0]["joinedDate"].ToString();


                    temp = true;
                }


                if (temp == true)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ert)
            {
                throw;
            }
        }
Exemple #25
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);
            }
        }
        public bool searchProduct(int id, string pname, Buisness_Logic.product prd)
        {
            // Buisness_Logic.product prd = new Buisness_Logic.product();

            bool temp = false;

            DataLayer.dbConnect con = new DataLayer.dbConnect();
            con.openConnection();
            try
            {
                string qr = "select * from tbl_product where productID=@id or name=@name";

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

                cmd.Parameters.AddWithValue("@id", id);
                cmd.Parameters.AddWithValue("@name", pname);

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

                da.Fill(dt);

                if (dt.Rows.Count > 0)
                {
                    prd.productID     = (int)dt.Rows[0]["productID"];
                    prd.name          = dt.Rows[0]["name"].ToString();
                    prd.make          = dt.Rows[0]["make"].ToString();
                    prd.qty           = (int)dt.Rows[0]["qty"];
                    prd.buying_price  = (double)dt.Rows[0]["buying_price"];
                    prd.selling_Price = (double)dt.Rows[0]["selling_price"];
                    prd.productType   = dt.Rows[0]["p_type"].ToString();
                    prd.photo         = (byte[])dt.Rows[0]["photo"];

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

            if (temp == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #27
0
        public bool searchWL_Items(int id, string pname, Buisness_Logic.nonRepairable_Item prd)
        {
            // Buisness_Logic.product prd = new Buisness_Logic.product();

            bool temp = false;

            DataLayer.dbConnect con = new DataLayer.dbConnect();
            con.openConnection();
            try
            {
                string qr = "select * from view_nonRepItems where invID=@id or name=@name";

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

                cmd.Parameters.AddWithValue("@id", id);
                cmd.Parameters.AddWithValue("@name", pname);

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

                da.Fill(dt);

                if (dt.Rows.Count > 0)
                {
                    prd.invID  = (int)dt.Rows[0]["invID"];
                    prd.name   = dt.Rows[0]["name"].ToString();
                    prd.make   = dt.Rows[0]["make"].ToString();
                    prd.qty    = (int)dt.Rows[0]["qty"];
                    prd.price  = (double)dt.Rows[0]["price"];
                    prd.weight = (double)dt.Rows[0]["weight"];
                    prd.model  = dt.Rows[0]["model"].ToString();
                    prd.photo  = (byte[])dt.Rows[0]["photo"];

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

            if (temp == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public bool searchAerobicMemOnly(int memID, string name, string nic, AreobicMember arm)
        {
            DataLayer.dbConnect con = new DataLayer.dbConnect();
            con.openConnection();
            bool temp = false;

            try
            {
                string q1 = "select * from veiw_areobicMember where memberID=@regNo or nic=@nic or name=@name";

                SqlCommand cmd1 = new SqlCommand(q1, con.getConnection());

                cmd1.Parameters.AddWithValue("@regNo", memID);
                cmd1.Parameters.AddWithValue("@nic", nic);
                cmd1.Parameters.AddWithValue("@name", name);

                SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
                DataTable      dt1 = new DataTable();

                da1.Fill(dt1);

                if (dt1.Rows.Count > 0)
                {
                    arm.MemberID     = int.Parse(dt1.Rows[0]["memberID"].ToString());
                    arm.name         = dt1.Rows[0]["name"].ToString();
                    arm.nic          = dt1.Rows[0]["nic"].ToString();
                    arm.dob          = dt1.Rows[0]["dob"].ToString();
                    arm.gender       = dt1.Rows[0]["gender"].ToString();
                    arm.addresss     = dt1.Rows[0]["address"].ToString();
                    arm.phone        = dt1.Rows[0]["phone"].ToString();
                    arm.service_type = dt1.Rows[0]["service_type"].ToString();

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

            if (temp == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public bool update_employee(employee g)
        {
            bool tup = false;

            try
            {
                DataLayer.dbConnect dbu = new DataLayer.dbConnect();

                dbu.openConnection();

                SqlCommand cmdu = null;

                string qup = "UPDATE tbl_employee set name=@name, dob=@dob, nic=@nic, address=@address , gender=@gender,email=@email, phone=@phone , position=@position ,profile=@profile,joinedDate=@jdate,photo=@photo where empID=@reg ";

                cmdu = new SqlCommand(qup, dbu.getConnection());
                cmdu.Parameters.AddWithValue("@name", g.name);
                cmdu.Parameters.AddWithValue("@dob", g.dob);
                cmdu.Parameters.AddWithValue("@address", g.address);
                cmdu.Parameters.AddWithValue("@nic", g.nic);
                cmdu.Parameters.AddWithValue("@gender", g.gender);
                cmdu.Parameters.AddWithValue("@phone", g.phone);
                cmdu.Parameters.AddWithValue("@reg", g.empID);
                cmdu.Parameters.AddWithValue("@email", g.email);
                cmdu.Parameters.AddWithValue("@position", g.position);
                cmdu.Parameters.AddWithValue("@photo", g.photo);
                cmdu.Parameters.AddWithValue("@profile", g.profile);
                cmdu.Parameters.AddWithValue("@jdate", g.joinedDate);

                cmdu.ExecuteNonQuery();

                tup = true;
            }
            catch (Exception epu)
            {
                // trnup.Rollback();
                MessageBox.Show(epu.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                throw;
            }

            if (tup == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #30
0
        private void dataGrid_generation_expense()
        {
            DataLayer.dbConnect con = new DataLayer.dbConnect();
            con.openConnection();

            string     q   = "select * from sales_finance";
            SqlCommand cmd = new SqlCommand(q, con.getConnection());

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

            da.Fill(dt);

            datagrid_expe.DataSource = dt;
        }