コード例 #1
0
        public List <cAssignedWork> getAssignedWorks()
        {
            List <cAssignedWork> works = new List <cAssignedWork>();
            SqlConnection        con   = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);

            if (con.State == System.Data.ConnectionState.Open)
            {
                con.Close();
            }
            con.Open();

            string        query  = "select * from AssignedWork";
            SqlCommand    cmd    = new SqlCommand(query, con);
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                cAssignedWork u1 = new cAssignedWork();
                u1.mId      = Convert.ToInt32(reader["mId"]);
                u1.aId      = Convert.ToInt32(reader["aId"]);
                u1.wId      = Convert.ToInt32(reader["wId"]);
                u1.aPrice   = Convert.ToInt32(reader["aPrice"]);
                u1.aRemarks = reader["aRemarks"].ToString();
                u1.aDueDate = Convert.ToDateTime(reader["aDueDate"]);
                u1.astatus  = reader["astatus"].ToString();
                works.Add(u1);
            }
            reader.Close();
            con.Close();

            con.Dispose();
            cmd.Dispose();
            return(works);;
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            cAssignedWork work = new cAssignedWork();

            work.mId      = Convert.ToInt32(new cMeaurementsBLL().getId(listBox1.Text));
            work.wId      = Convert.ToInt32(comboBox2.SelectedItem.GetType().GetProperty("wId").GetValue(comboBox2.SelectedItem));
            work.astatus  = "pending";
            work.aDueDate = dateTimePicker1.Value;
            work.aRemarks = textBox1.Text.Trim();
            work.aPrice   = Convert.ToInt32(textBox2.Text.Trim());
            if (work.aPrice > -1)
            {
                if (work.aRemarks != "")
                {
                    new cAssignedWorkBLL().InsertAssignedWork(work);
                    updateDataGrid();
                    MessageBox.Show("data added...!!!", "Sucsses", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("enter remarks for work...!!!", "alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
            else
            {
                MessageBox.Show("enter valid price for work...!!!", "alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
        private void dgvUsers_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int selectedRowIndex    = this.dgvUsers.SelectedCells[0].RowIndex;
            int selectedColumnIndex = this.dgvUsers.SelectedCells[0].ColumnIndex;

            if (selectedColumnIndex == 0)//update
            {
                //MessageBox.Show("update click  "+this.dgvUsers.Rows[selectedRowIndex].Cells[4].Value);access row value
                cAssignedWork w1 = new cAssignedWork();
                w1.aId      = Convert.ToInt32(this.dgvUsers.Rows[selectedRowIndex].Cells[2].Value);
                w1.wId      = Convert.ToInt32(this.dgvUsers.Rows[selectedRowIndex].Cells[3].Value);
                w1.mId      = Convert.ToInt32(this.dgvUsers.Rows[selectedRowIndex].Cells[4].Value);
                w1.astatus  = this.dgvUsers.Rows[selectedRowIndex].Cells[5].Value.ToString();
                w1.aDueDate = Convert.ToDateTime(this.dgvUsers.Rows[selectedRowIndex].Cells[6].Value);
                w1.aRemarks = this.dgvUsers.Rows[selectedRowIndex].Cells[7].Value.ToString();
                w1.aPrice   = Convert.ToInt32(this.dgvUsers.Rows[selectedRowIndex].Cells[8].Value);

                if ((w1.astatus == "complete" || w1.astatus == "pending") && w1.astatus != "")
                {
                    new cAssignedWorkBLL().UpdateAssignedWork(w1);
                    updatedata();
                    MessageBox.Show("Data Updated...!!!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("status type must be \"complete\" or \"pending\"...!!!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
            else if (selectedColumnIndex == 1)//delete
            {
                new cAssignedWorkBLL().RemoveAssignedWork(Convert.ToInt32(this.dgvUsers.Rows[selectedRowIndex].Cells[2].Value));
                updatedata();
                MessageBox.Show("Data Deleted...!!!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #4
0
        public int InsertAssignedWork(cAssignedWork assignedWork)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);

            if (con.State.ToString() == "open")
            {
                con.Close();
            }
            con.Open();
            string query = "INSERT into AssignedWork ([wId],[mId],[astatus],[aDueDate],[aRemarks],[aPrice])" +
                           " values('" + assignedWork.wId + "','" + assignedWork.mId + "','" + assignedWork.astatus + "','" + assignedWork.aDueDate + "','" + assignedWork.aRemarks + "','" + assignedWork.aPrice + "')";
            SqlCommand cmd    = new SqlCommand(query, con);
            var        result = cmd.ExecuteNonQuery();

            con.Close();
            cmd.Dispose();
            con.Dispose();
            return(result);
        }
コード例 #5
0
        public int UpdateAssignedWork(cAssignedWork w1)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);

            if (con.State == System.Data.ConnectionState.Open)
            {
                con.Close();
            }
            con.Open();
            string query = "UPDATE AssignedWork " +
                           "SET mId = '" + w1.mId + "' , wId = '" + w1.wId + "' , aPrice = '" + w1.aPrice + "' , aRemarks = '" + w1.aRemarks + "' , aDueDate = '" + w1.aDueDate + "' , astatus = '" + w1.astatus + "' " +
                           " WHERE aId ='" + w1.aId + "'";
            SqlCommand cmd    = new SqlCommand(query, con);
            var        result = cmd.ExecuteNonQuery();

            con.Close();
            cmd.Dispose();
            con.Dispose();
            return(result);
        }
コード例 #6
0
 public int UpdateAssignedWork(cAssignedWork w1)
 {
     return(new cAssignedWorkDAL().UpdateAssignedWork(w1));
 }
コード例 #7
0
 public int InsertAssignedWork(cAssignedWork assignedWork)
 {
     return(new cAssignedWorkDAL().InsertAssignedWork(assignedWork));
 }