public bool insertW(AssignWork1 obj) { string conStr = "server=DESKTOP-RO7ULCV;database=SQLdb;Integrated Security=SSPI;"; SqlConnection con = new SqlConnection(conStr); try { con.Open(); string query = "INSERT INTO Assign(Name,Task,Comp,pend,total,C,P,due,R,isCompleted,Isdue)VALUES ('" + obj.Name + "', '" + obj.Task + "', '" + 0 + "', '" + 1 + "','" + 0 + "','" + obj.C + "','" + obj.P + "','" + obj.due + "','" + obj.R + "','" + obj.isCompleted + "','" + obj.Isdue + "');"; SqlCommand cmd = new SqlCommand(query, con); cmd.ExecuteNonQuery(); } catch (SqlException ex) { return(false); throw ex; } finally { if (con.State == ConnectionState.Open) { con.Close(); } } return(true); }
protected void add_Click(object sender, EventArgs e) { if (this.TextBox1.Text == "" || this.price.Text == "" || this.dueDate.Text == "" || this.remarks.Text == "") { Response.Write("<script> alert('Fill the required all fields'); </script> "); } else { i = i + 1; AssignWork1 obj = new AssignWork1(); obj.Name = this.selectWorker.Text; obj.Task = i; obj.P = Convert.ToInt16(this.price.Text); obj.due = Convert.ToDateTime(this.dueDate.Text); obj.C = this.selectCustomer.Text; obj.R = this.remarks.Text; obj.isCompleted = false; obj.Isdue = false; AssignWork1BLL wbll = new AssignWork1BLL(); try { if (wbll.insertW(obj)) { Response.Write("<script>alert('Successfully Added!!!!!');</script>"); } else { Response.Write("<script>alert('Failed to Add!!!!!');</script>"); } this.TextBox1.Text = ""; this.price.Text = ""; this.remarks.Text = ""; this.dueDate.Text = ""; this.GridView1.DataSource = new TMS.BLL.AssignWork1BLL().getAllWorkAssignmentInList(); this.GridView1.DataBind(); } catch (Exception ex) { throw ex; } } }
public List <AssignWork1> getAllWorkAssignmentINListF() { string conStr = "server=DESKTOP-RO7ULCV;database=SQLdb;Integrated Security=SSPI;"; SqlConnection con = new SqlConnection(conStr); try { con.Open(); string query = "select * from Assign"; SqlCommand cmd = new SqlCommand(query, con); SqlDataReader reader = cmd.ExecuteReader(); List <AssignWork1> list = new List <AssignWork1>(); while (reader.Read()) { AssignWork1 worker = new AssignWork1(); worker.Name = Convert.ToString(reader["Name"]); worker.Task = Convert.ToInt32(reader["Task"]); worker.Comp = Convert.ToInt32(reader["Comp"]); worker.pend = Convert.ToInt32(reader["pend"]); worker.total = Convert.ToString(reader["total"]); worker.C = Convert.ToString(reader["C"]); worker.P = Convert.ToInt16(reader["P"]); worker.R = Convert.ToString(reader["R"]); list.Add(worker); } reader.Close(); return(list); } catch (SqlException ex) { throw ex; } finally { if (con.State == System.Data.ConnectionState.Open) { con.Close(); } } }
public bool insertW(AssignWork1 obj) { return(new TMS.DAL.AssignWork1DAL().insertW(obj)); }