Example #1
0
        public static DbStatusEntity[] UpdateData(TaskMasterParamEntity obj, Int64 id) //Update data in database
        {
            var details = new List <DbStatusEntity>();

            try
            {
                details.Add(new TaskMasterDAO().UpdateTaskMaster(obj, id));
            }
            catch (Exception ex)
            {
                details.Clear();
                details.Add(new DbStatusEntity(ex.Message));
            }
            return(details.ToArray());
        }
Example #2
0
        public static DbStatusEntity[] InsertData(TaskMasterParamEntity obj)
        {
            var details = new List <DbStatusEntity>();

            try
            {
                details.Add(new TaskMasterDAO().InsertTaskMaster(obj));
            }
            catch (Exception ex)
            {
                details.Clear();
                details.Add(new DbStatusEntity(ex.Message));
            }
            return(details.ToArray());
        }
Example #3
0
        public DbStatusEntity UpdateTaskMaster(TaskMasterParamEntity obj, Int64 id)
        {
            DbStatusEntity objreturn = new DbStatusEntity();
            string         CS        = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;

            try
            {
                using (SqlConnection con = new SqlConnection(CS))
                {
                    SqlCommand cmd = new SqlCommand("USP_UpdateTaskMaster", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@T_ID", id);
                    cmd.Parameters.AddWithValue("@T_NAME", obj.T_NAME);
                    cmd.Parameters.AddWithValue("@T_DESC", obj.T_DESC);
                    cmd.Parameters.AddWithValue("@PRIORITY", obj.PRIORITY);
                    cmd.Parameters.AddWithValue("@RECURRING_TYPE", obj.RECURRING_TYPE);
                    cmd.Parameters.AddWithValue("@RECURRING_DAYS", obj.RECURRING_DAYS);
                    cmd.Parameters.AddWithValue("@RECURRING_START_DAY", obj.RECURRING_START_DAY);
                    cmd.Parameters.AddWithValue("@RECURRING_START_DATE", obj.RECURRING_START_DATE);
                    cmd.Parameters.AddWithValue("@RECURRING_END_DATE", obj.RECURRING_END_DATE);
                    cmd.Parameters.AddWithValue("@ACTIVE_STATUS", obj.ACTIVE_STATUS);
                    cmd.Parameters.AddWithValue("@MAPPED_CLIENTS", obj.MAPPED_CLIENTS);
                    cmd.Parameters.AddWithValue("@MAPPED_CLI_CAT", obj.MAPPED_CLI_CAT);

                    DataTable dtsub = new DataTable();
                    dtsub.Columns.Add("TS_ID", typeof(int));
                    dtsub.Columns.Add("TS_NAME", typeof(string));
                    dtsub.Columns.Add("USER_ID", typeof(int));
                    dtsub.Columns.Add("SL_NO", typeof(int));

                    foreach (TaskMasterSubParamEntity objsub in obj.SUBARR)
                    {
                        DataRow dr = dtsub.NewRow();
                        dr["TS_ID"]   = 0;
                        dr["TS_NAME"] = objsub.STAGE;
                        dr["USER_ID"] = objsub.USER_ID;
                        dr["SL_NO"]   = objsub.SLNO;
                        dtsub.Rows.Add(dr);
                    }

                    SqlParameter sqlParam = cmd.Parameters.AddWithValue("@TVP", dtsub);
                    sqlParam.SqlDbType = SqlDbType.Structured;

                    DataTable dtdocs = new DataTable();
                    dtdocs.Columns.Add("SL_NO", typeof(int));
                    dtdocs.Columns.Add("DOC_NAME", typeof(string));

                    foreach (TaskDocumentEntity objdoc in obj.DOCARR)
                    {
                        DataRow dr = dtdocs.NewRow();
                        dr["SL_NO"]    = objdoc.SL_NO;
                        dr["DOC_NAME"] = objdoc.DOC_NAME;
                        dtdocs.Rows.Add(dr);
                    }

                    SqlParameter sqlParamdoc = cmd.Parameters.AddWithValue("@TVPDOCS", dtdocs);
                    sqlParamdoc.SqlDbType = SqlDbType.Structured;

                    cmd.Parameters.Add("@RESULT", SqlDbType.Int);
                    cmd.Parameters["@RESULT"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@CNT", SqlDbType.Int);
                    cmd.Parameters["@CNT"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@MSG", SqlDbType.NVarChar, 500);
                    cmd.Parameters["@MSG"].Direction = ParameterDirection.Output;
                    con.Open();
                    cmd.ExecuteNonQuery();
                    objreturn.RESULT = Convert.ToInt32(cmd.Parameters["@RESULT"].Value);
                    objreturn.CNT    = Convert.ToInt32(cmd.Parameters["@CNT"].Value);
                    objreturn.MSG    = Convert.ToString(cmd.Parameters["@MSG"].Value);
                    con.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(objreturn);
        }