Example #1
0
        protected void SaveTask()
        {
            Task            task        = new Task();
            TaskDL          objTaskDL   = new TaskDL();
            ProcessResponse objResponse = new ProcessResponse();

            if (Convert.ToInt64(hdActionId.Value) > 0)
            {
                objResponse.Command = "UPDATE";
                task.ActionId       = Convert.ToInt64(hdActionId.Value);
            }
            else
            {
                objResponse.Command = "INSERT";
            }

            task.Action       = action.Value;
            task.Remarks      = remarks.Value;
            task.ToDoDateTime = temp;
            task.ActionStatus = ddlStatus.SelectedValue;
            task.SendAlert    = false;
            //task.AlertDatetime = DateTime.Now;
            task.AlertMailTo = "";
            task.AlertSent   = false;
            task.EntryDate   = DateTime.Now;
            task.UpdateDate  = DateTime.Now;

            objResponse.IsDebugMode = false;
            objResponse.IsDebugStop = false;

            objResponse   = objTaskDL.SaveTask(objResponse, task);
            msg.InnerText = objResponse.CustomMessage;
            msg.Attributes.Add("class", (objResponse.IsSuccess ? "alert alert-success" : "alert alert-danger"));
        }
Example #2
0
        public DataTable GetAllTask(ProcessResponse response, Task objTask)
        {
            DataTable     dt        = new DataTable();
            SqlDataReader objReader = default(SqlDataReader);

            response.Command = "SELECTALL";
            objCmd.Parameters.Add("@Command", SqlDbType.VarChar, 50).Value      = response.Command;
            objCmd.Parameters.Add("@Action", SqlDbType.VarChar, 50).Value       = objTask.Action;
            objCmd.Parameters.Add("@ActionStatus", SqlDbType.VarChar, 50).Value = objTask.ActionStatus;
            objCmd.Parameters.Add("@FromDate", SqlDbType.VarChar, 50).Value     = response.FromDate;
            objCmd.Parameters.Add("@ToDate", SqlDbType.VarChar, 50).Value       = response.ToDate;
            objCmd.Parameters.Add("@SortBy", SqlDbType.VarChar, 50).Value       = response.SortBy;
            objCmd.Parameters.Add("@SortOrder", SqlDbType.VarChar, 50).Value    = response.SortOrder;

            //////////////////////////////////////////
            //' '' // START : For Debuging ==================================
            if (response.IsDebugMode)
            {
                string strREsponse = "";
                strREsponse += " <Br />exec Usp_Manage_Actions <Br />";

                for (int i = 0; i <= objCmd.Parameters.Count - 1; i++)
                {
                    if (objCmd.Parameters[i].Value != null)
                    {
                        strREsponse += objCmd.Parameters[i].ParameterName + " = '" + objCmd.Parameters[i].Value.ToString().Replace("'", "''") + "' ," + "<br/>";
                    }
                }

                HttpContext.Current.Response.Write(strREsponse);
                if (response.IsDebugStop)
                {
                    HttpContext.Current.Response.End();
                }
            }
            /////// End : For Debuging //////////////////////////////////////////

            objReader = objCon.Usp_Get_DataReader("Usp_Manage_Actions", objCmd);

            if (objReader != null && objReader.HasRows)
            {
                dt.Load(objReader);
            }


            if (objReader != null && !objReader.IsClosed)
            {
                objReader.Close();
            }
            objReader = null;
            objCmd.Dispose();
            objCmd = null;
            objCon.CloseConnection();
            objCon = null;

            return(dt);
        }
Example #3
0
        public ProcessResponse DeleteTask(ProcessResponse response, Task objTask)
        {
            SqlDataReader objReader = default(SqlDataReader);

            try
            {
                objCmd.Parameters.Add("@Command", System.Data.SqlDbType.VarChar).Value = response.Command;
                objCmd.Parameters.Add("@ActionId", System.Data.SqlDbType.BigInt).Value = objTask.ActionId;

                objReader = objCon.Usp_Get_DataReader("Usp_Manage_Actions", objCmd);
                if (objReader.HasRows)
                {
                    objReader.Read();
                    objResponse.IsSuccess     = Convert.ToBoolean(objReader["IsSuccess"]);
                    objResponse.Identity      = Convert.ToUInt32(objReader["IdentityValue"]);
                    objResponse.Message       = Convert.ToString(objReader["ProcessMessage"]);
                    objResponse.CustomMessage = "Task Information deleted!";
                }
                else
                {
                    objResponse.IsSuccess = false;
                    objResponse.Identity  = 0;
                    objResponse.Message   = "Task Information delete process failed";
                }
            }
            catch (Exception ex)
            {
                objResponse.IsSuccess = false;
                objResponse.Identity  = 0;
                objResponse.Message   = ex.Message.ToString();
            }
            finally
            {
                if (!objReader.IsClosed)
                {
                    objReader.Close();
                }
                objReader = null;
                objCmd.Dispose();
                objCmd = null;
                objCon.CloseConnection();
                objCon = null;
            }

            return(objResponse);
        }
Example #4
0
        public Task GetTask(ProcessResponse response, Task objTask)
        {
            SqlDataReader objReader = default(SqlDataReader);

            objCmd.Parameters.Add("@Command", SqlDbType.VarChar, 50).Value         = response.Command;
            objCmd.Parameters.Add("@ActionId", System.Data.SqlDbType.BigInt).Value = objTask.ActionId;

            objReader = objCon.Usp_Get_DataReader("Usp_Manage_Actions", objCmd);

            if (objReader.HasRows)
            {
                while (objReader.Read())
                {
                    objTask.ActionId     = Convert.ToInt64(objReader["ActionId"]);
                    objTask.UserId       = Convert.ToInt32(objReader["UserId"]);
                    objTask.Action       = Convert.ToString(objReader["Action"]);
                    objTask.Remarks      = Convert.ToString(objReader["Remarks"]);
                    objTask.ToDoDateTime = Convert.ToDateTime(objReader["ToDoDateTime"]);
                    objTask.ActionStatus = Convert.ToString(objReader["ActionStatus"]);
                    objTask.SendAlert    = Convert.ToBoolean(objReader["SendAlert"]);
                    if (!String.IsNullOrEmpty(objReader["AlertDatetime"].ToString()))
                    {
                        objTask.AlertDatetime = Convert.ToDateTime(objReader["AlertDatetime"]);
                    }
                    objTask.AlertMailTo = Convert.ToString(objReader["AlertMailTo"]);
                    objTask.AlertSent   = Convert.ToBoolean(objReader["AlertSent"]);
                    objTask.EntryDate   = Convert.ToDateTime(objReader["EntryDate"]);
                    objTask.UpdateDate  = Convert.ToDateTime(objReader["UpdateDate"]);
                }
            }


            if (!objReader.IsClosed)
            {
                objReader.Close();
            }
            objReader = null;
            objCmd.Dispose();
            objCmd = null;
            objCon.CloseConnection();
            objCon = null;


            return(objTask);
        }
Example #5
0
        protected void gvTask_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            //  var current = gvTask.CurrentRow;
            if ((e.CommandName.ToLower() != "sort")) // Means that you've not clicked the column header
            {
                btnReset_Click(sender, e);

                Task            task        = new Task();
                TaskDL          objTaskDL   = new TaskDL();
                ProcessResponse objResponse = new ProcessResponse();

                task.ActionId    = Convert.ToInt64(e.CommandArgument);
                hdActionId.Value = Convert.ToString(task.ActionId);

                if (e.CommandName == "EditTask")
                {
                    objResponse.Command = "Select";
                    task = objTaskDL.GetTask(objResponse, task);


                    if (task != null)
                    {
                        action.Focus();
                        action.Value            = task.Action;
                        remarks.Value           = task.Remarks;
                        date.Value              = task.ToDoDateTime.ToShortDateString();
                        time.Value              = task.ToDoDateTime.ToShortTimeString();
                        ddlStatus.SelectedIndex = -1;
                        ddlStatus.Items.FindByValue(task.ActionStatus).Selected = true;
                    }
                }

                else if (e.CommandName == "DeleteTask")
                {
                    objResponse.Command = "Delete";

                    objResponse = objTaskDL.DeleteTask(objResponse, task);

                    msg.InnerText = objResponse.CustomMessage;
                    msg.Attributes.Add("class", (objResponse.IsSuccess ? "alert alert-success" : "alert alert-danger"));
                }

                LoadTasks();
            }
        }
Example #6
0
        protected void LoadTasks(string SortExpression = null, string sortingDirection = null)
        {
            Task            task        = new Task();
            TaskDL          objTaskDL   = new TaskDL();
            ProcessResponse objResponse = new ProcessResponse();

            objResponse.Command = "SELECTALL";

            if (keyword.Value.Trim() != "")
            {
                task.Action = keyword.Value.Trim();
            }
            if (fromdate.Value.Trim() != "")
            {
                objResponse.FromDate = fromdate.Value;
            }
            if (todate.Value.Trim() != "")
            {
                objResponse.ToDate = todate.Value;
            }

            task.ActionStatus = ddlSearchStatus.SelectedValue;

            if (SortExpression == null)
            {
                SortExpression = "EntryDate";
            }
            if (sortingDirection == null)
            {
                sortingDirection = "Asc";
            }
            objResponse.SortBy    = SortExpression;   // "EntryDate";
            objResponse.SortOrder = sortingDirection; //"Asc";


            objResponse.IsDebugMode = false;
            objResponse.IsDebugStop = false;

            gvTask.DataSource = objTaskDL.GetAllTask(objResponse, task);
            gvTask.DataBind();
        }
Example #7
0
        public ProcessResponse SaveTask(ProcessResponse response, Task objTask)
        {
            SqlDataReader objReader = default(SqlDataReader);

            try
            {
                objCmd.Parameters.Add("@Command", System.Data.SqlDbType.VarChar).Value        = response.Command;
                objCmd.Parameters.Add("@ActionId", System.Data.SqlDbType.BigInt).Value        = objTask.ActionId;
                objCmd.Parameters.Add("@UserId", System.Data.SqlDbType.Int).Value             = objTask.UserId;
                objCmd.Parameters.Add("@Action", System.Data.SqlDbType.VarChar).Value         = objTask.Action;
                objCmd.Parameters.Add("@Remarks", System.Data.SqlDbType.VarChar).Value        = objTask.Remarks;
                objCmd.Parameters.Add("@ToDoDateTime", System.Data.SqlDbType.DateTime).Value  = objTask.ToDoDateTime;
                objCmd.Parameters.Add("@ActionStatus", System.Data.SqlDbType.VarChar).Value   = objTask.ActionStatus;
                objCmd.Parameters.Add("@SendAlert", System.Data.SqlDbType.Bit).Value          = objTask.SendAlert;
                objCmd.Parameters.Add("@AlertDatetime", System.Data.SqlDbType.DateTime).Value = objTask.AlertDatetime;
                objCmd.Parameters.Add("@AlertMailTo", System.Data.SqlDbType.VarChar).Value    = objTask.AlertMailTo;
                objCmd.Parameters.Add("@AlertSent", System.Data.SqlDbType.Bit).Value          = objTask.AlertSent;
                objCmd.Parameters.Add("@EntryDate", System.Data.SqlDbType.DateTime).Value     = objTask.EntryDate;
                objCmd.Parameters.Add("@UpdateDate", System.Data.SqlDbType.DateTime).Value    = objTask.UpdateDate;


                //////////////////////////////////////////
                //' '' // START : For Debuging ==================================

                if (response.IsDebugMode)
                {
                    string strREsponse = "";
                    strREsponse += " <Br />exec Usp_Manage_Actions <Br />";

                    for (int i = 0; i <= objCmd.Parameters.Count - 1; i++)
                    {
                        if (objCmd.Parameters[i].Value != null)
                        {
                            strREsponse += objCmd.Parameters[i].ParameterName + " = '" + objCmd.Parameters[i].Value.ToString().Replace("'", "''") + "' ," + "<br/>";
                        }
                    }

                    HttpContext.Current.Response.Write(strREsponse);
                    if (response.IsDebugStop)
                    {
                        HttpContext.Current.Response.End();
                    }
                }
                /////// End : For Debuging //////////////////////////////////////////

                objReader = objCon.Usp_Get_DataReader("Usp_Manage_Actions", objCmd);
                if (objReader.HasRows)
                {
                    objReader.Read();
                    objResponse.IsSuccess     = Convert.ToBoolean(objReader["IsSuccess"]);
                    objResponse.Identity      = Convert.ToUInt32(objReader["IdentityValue"]);
                    objResponse.Message       = Convert.ToString(objReader["ProcessMessage"]);
                    objResponse.CustomMessage = "Task Information saved!";
                }
                else
                {
                    objResponse.IsSuccess = false;
                    objResponse.Identity  = 0;
                    objResponse.Message   = "Task Information save process failed";
                }
            }
            catch (Exception ex)
            {
                objResponse.IsSuccess = false;
                objResponse.Identity  = 0;
                objResponse.Message   = ex.Message.ToString();
            }
            finally
            {
                if (objReader != null && !objReader.IsClosed)
                {
                    objReader.Close();
                }
                objReader = null;
                objCmd.Dispose();
                objCmd = null;
                objCon.CloseConnection();
                objCon = null;
            }

            return(objResponse);
        }