public void insert_complaindetails(ComplainDetails cd)
        {
            SqlConnection C = new SqlConnection(ConnectionString);
            var           complain_insert = new SqlCommand("INSERT INTO [dbo].[ComplainDetails] ([Complain_Id], [Clientid], [ProblemDetails], [ProblemStatus], [Date] ) VALUES (@Complain_Id, @Clientid, @ProblemDetails, @ProblemStatus, @Date)", C);
            SqlParameter  p1 = new SqlParameter("@Complain_Id ", SqlDbType.VarChar, 50);

            p1.Value = cd.Complain_Id;
            SqlParameter p2 = new SqlParameter("@Clientid ", SqlDbType.VarChar, 50);

            p2.Value = cd.ClientId;
            SqlParameter p3 = new SqlParameter("@ProblemDetails ", SqlDbType.VarChar);

            p3.Value = cd.ProblemDetails;
            SqlParameter p4 = new SqlParameter("@ProblemStatus ", SqlDbType.VarChar, 50);

            p4.Value = cd.ProblemStatus;
            SqlParameter p5 = new SqlParameter("@Date ", SqlDbType.DateTime);

            p5.Value = cd.Date;

            complain_insert.Parameters.Add(p1);
            complain_insert.Parameters.Add(p2);
            complain_insert.Parameters.Add(p3);
            complain_insert.Parameters.Add(p4);
            complain_insert.Parameters.Add(p5);

            C.Open();
            complain_insert.ExecuteNonQuery();
            C.Close();
        }
 public complaintsmr(ComplainDetails _cds)
 {
     InitializeComponent();
     _compidtextbox.Text         = _cds.Complain_Id.ToString();
     cdtextbox.Text              = _cds.ClientId.ToString();
     _probdate.Value             = _cds.Date;
     _problemdetailstextbox.Text = _cds.ProblemDetails.ToString();
     probstatus.Text             = _cds.ProblemStatus.ToString();
     delete.Enabled              = true;
     modify.Enabled              = false;
     _probdate.Enabled           = false;
     probstatus.Enabled          = false;
 }
        public bool UpdateComplainDetails(ComplainDetails comd_obj)
        {
            SqlConnection C = new SqlConnection(ConnectionString);

            SqlCommand command = new SqlCommand("UPDATE [dbo].[ComplainDetails]  SET [ClientId]=@ClientId, [ProblemDetails]=@ProblemDetails,[ProblemStatus]=@ProblemStatus,[Date]=@Date WHERE [Complain_Id] = @Complain_Id", C);

            SqlParameter p1 = new SqlParameter("@ClientId", System.Data.SqlDbType.VarChar, 20);

            p1.Value = comd_obj.ClientId;
            command.Parameters.Add(p1);

            SqlParameter p2 = new SqlParameter("@ProblemDetails", System.Data.SqlDbType.VarChar, 25);

            p2.Value = comd_obj.ProblemDetails;
            command.Parameters.Add(p2);

            SqlParameter p3 = new SqlParameter("@ProblemStatus", System.Data.SqlDbType.VarChar, 50);

            p3.Value = comd_obj.ProblemStatus;
            command.Parameters.Add(p3);


            SqlParameter p4 = new SqlParameter("@Date", System.Data.SqlDbType.DateTime);

            p4.Value = comd_obj.Date;
            command.Parameters.Add(p4);
            SqlParameter p5 = new SqlParameter("@Complain_Id", System.Data.SqlDbType.VarChar);

            p5.Value = comd_obj.Complain_Id;
            command.Parameters.Add(p5);

            C.Open();

            int result = command.ExecuteNonQuery();

            C.Close();
            return(result > 0);
        }