public void UpdateSalesRepCsById(RaiseSalesCsUI obj) { SqlConnection conn = new SqlConnection(); var status = "N"; if (obj.Status) { status = "Y"; } conn.ConnectionString = CONNSTRING; var strSqlContactStmt = @"UPDATE RaiseCSSalesRep SET Complaint=@complaint, OutCome=@outCome , Question=@question, Status=@status , ModifiedDate=CURRENT_TIMESTAMP WHERE Id=@Id"; using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = conn; conn.Open(); cmd.CommandText = strSqlContactStmt; cmd.Parameters.Add("@Complaint", SqlDbType.VarChar).Value = obj.Complaint; cmd.Parameters.Add("@outCome", SqlDbType.VarChar).Value = obj.OutCome; cmd.Parameters.Add("@Id", SqlDbType.Int).Value = obj.Id; cmd.Parameters.Add("@question", SqlDbType.NVarChar).Value = obj.Question; cmd.Parameters.Add("@status", SqlDbType.NVarChar).Value = status; cmd.CommandText = strSqlContactStmt; cmd.ExecuteNonQuery(); } conn.Close(); }
public RaiseSalesCsUI ReadSalesRepCsById(int Id) { var obj = new RaiseSalesCsUI(); obj.Id = Id; using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = CONNSTRING; using (SqlCommand cmd = new SqlCommand()) { var strSqlContactStmt = @"SELECT rs.Id, rs.Complaint, rs.OutCome,rs.OrderId, rs.CompanyId, rs.ContactId,rs.CreatedDate,rs.Question,rs.Status,rs.CsType from RaiseCSSalesRep rs where rs.Id=@rId"; cmd.Parameters.AddWithValue("@rId", SqlDbType.Int).Value = Id; cmd.CommandText = strSqlContactStmt; cmd.Connection = conn; conn.Open(); using (SqlDataReader sdr = cmd.ExecuteReader()) { if (sdr.HasRows) { while (sdr.Read()) { var complaint = sdr["Complaint"].ToString(); var outCome = ""; var csType = "1"; var question = ""; if (sdr["OutCome"] != DBNull.Value) { outCome = sdr["OutCome"].ToString(); } if (sdr["Question"] != DBNull.Value) { question = sdr["Question"].ToString(); } if (sdr["CsType"] != DBNull.Value) { csType = sdr["CsType"].ToString(); } obj.CsTyte = csType.ToString(); obj.Complaint = complaint; obj.OutCome = outCome; obj.orderId = sdr["OrderId"].ToString(); obj.contactId = sdr["ContactId"].ToString(); obj.companyId = sdr["CompanyId"].ToString(); obj.Question = question; if (sdr["Status"] != DBNull.Value) { if (sdr["Status"].ToString() == "Y") { obj.Status = true; } } } } } } } return(obj); }