public Int64 SaveIssueDetail(IssueDetail id)
        {
            //string dbcs = "Data source=.;database=MantisDB;Integrated Security = SSPI";
            InitializeConnectionString();
            SqlConnection con = new SqlConnection(dbcs);
            SqlCommand    cmd = new SqlCommand();

            cmd.CommandText = "SaveIssueDetail";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection  = con;

            cmd.Parameters.Add(new SqlParameter("@MantisId", id.MantisID));
            cmd.Parameters.Add(new SqlParameter("@Slno", id.SLNO));
            cmd.Parameters.Add(new SqlParameter("@Summary", id.Summary));
            cmd.Parameters.Add(new SqlParameter("@AssingedBy", id.AssingedBy));
            //cmd.Parameters.Add(new SqlParameter("@ReportDate", null));

            cmd.Parameters.Add(new SqlParameter("@Description", id.Description));

            SqlParameter parId = new SqlParameter();

            parId.Direction     = ParameterDirection.Output;
            parId.ParameterName = "@Id";
            parId.DbType        = DbType.Int64;
            cmd.Parameters.Add(parId);

            con.Open();
            cmd.ExecuteNonQuery();

            con.Close();

            return(Convert.ToInt64(parId.Value) > 0 ? Convert.ToInt64(parId.Value) : -1);
        }
        public IEnumerable <IssueDetail> GetIssueDetails(long MantisId)
        {
            //string dbcs = "Data source=.;database=MantisDB;Integrated Security = SSPI";
            InitializeConnectionString();
            SqlConnection con = new SqlConnection(dbcs);
            SqlCommand    cmd = new SqlCommand();

            cmd.CommandText = "select * from IssueDetail where MantisId = " + MantisId + " order by SLNo";
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataReader dr = cmd.ExecuteReader();

            List <IssueDetail> issueDetails = new List <IssueDetail>();

            while (dr.Read())
            {
                IssueDetail obj = new IssueDetail();
                obj.MantisID       = (long)dr["MantisId"];
                obj.SLNO           = Convert.ToByte(dr["Slno"]);
                obj.Summary        = dr["Summary"].ToString();
                obj.AssingedBy     = dr["AssingedBy"].ToString();
                obj.ReportDate     = Convert.ToDateTime(dr["ReportDate"]);
                obj.Description    = dr["Description"].ToString();
                obj.Priority       = dr["Priority"].ToString();
                obj.AssingedToList = GetAssingedToListById(obj.MantisID, obj.SLNO);
                //obj.AssingedToLists = GetAssingedToList(obj.MantisId, obj.Slno); //Get the list of AssingedToList
                issueDetails.Add(obj);
            }

            dr.Close();
            con.Close();

            return(issueDetails);
        }
        public IssueDetail CreateNewStep(long?MantisId)
        {
            //string dbcs = "Data source=.;database=MantisDB;Integrated Security = SSPI";
            InitializeConnectionString();
            SqlConnection con = new SqlConnection(dbcs);
            SqlCommand    cmd = new SqlCommand();

            cmd.CommandText = "select * from IssueDetail where MantisId = " + MantisId + " and Slno = (select max(slno) from IssueDetail where mantisid = " + MantisId + " )";
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataReader dr = cmd.ExecuteReader();

            IssueDetail obj = new IssueDetail();

            while (dr.Read())
            {
                obj.MantisID       = (long)dr["MantisId"];
                obj.SLNO           = Convert.ToByte(dr["Slno"]);
                obj.Summary        = dr["Summary"].ToString();
                obj.AssingedBy     = dr["AssingedBy"].ToString();
                obj.ReportDate     = Convert.ToDateTime(dr["ReportDate"]);
                obj.Description    = dr["Description"].ToString();
                obj.Priority       = dr["Priority"].ToString();
                obj.AssingedToList = GetAssingedToListById(obj.MantisID, obj.SLNO);
            }

            dr.Close();
            con.Close();

            return(obj);
        }
        public IEnumerable <IssueDetail> GetMasterIssueDetails()
        {
            //string dbcs = "Data source=.;database=MantisDB;Integrated Security = SSPI";
            InitializeConnectionString();
            SqlConnection con = new SqlConnection(dbcs);
            SqlCommand    cmd = new SqlCommand();

            //cmd.CommandText = "select * from IssueDetail where SLNo = 1 order by MantisId desc";
            //cmd.CommandText = "select a.*, m.StartDate, m.CurrentStatus, StatusDate from IssueDetail a, IssueDetailMaster m where a.MantisId = m.MantisId  and a.SLNo = 1 order by a.MantisId desc";
            cmd.CommandText =
                "select a.MantisId, a.SLNo, m.IssueTitle Summary, a.AssingedBy, a.ReportDate,a.Description ,"
                + " m.Priority,m.TypeOfWork, m.TaskComplexity, m.StartDate, m.CurrentStatus, StatusDate , Isnull(e.Estimate,'-1') Estimated "
                + " from IssueDetail a inner join IssueDetailMaster m on a.MantisId = m.MantisId "
                + " left join (select * from Estimate where slno=1) e on m.MantisId = e.MantisId"
                + " where  a.SLNo = 1 order by a.MantisId desc";


            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            con.Open();
            SqlDataReader dr = cmd.ExecuteReader();

            List <IssueDetail> issueDetails = new List <IssueDetail>();

            while (dr.Read())
            {
                IssueDetail obj = new IssueDetail();
                obj.MantisID    = (long)dr["MantisId"];
                obj.SLNO        = Convert.ToByte(dr["Slno"]);
                obj.Summary     = dr["Summary"].ToString();
                obj.AssingedBy  = dr["AssingedBy"].ToString();
                obj.ReportDate  = Convert.ToDateTime(dr["ReportDate"]);
                obj.Description = dr["Description"].ToString();
                obj.Priority    = dr["Priority"].ToString();
                obj.TypeOfWork  = dr["TypeOfWork"].ToString();
                //obj.TaskStatus = dr["TaskStatus"].ToString();
                //obj.TaskSubStatus = dr["TaskSubStatus"].ToString();
                obj.TaskComplexity = dr["TaskComplexity"].ToString();
                obj.StartDate      = (DateTime)dr["StartDate"];
                obj.CurrentStatus  = dr["CurrentStatus"].ToString();
                obj.StatusDate     = (DateTime)dr["StatusDate"];
                obj.Estimated      = dr["Estimated"].ToString();
                obj.AssingedToList = GetAssingedToListById(obj.MantisID, obj.SLNO);
                //obj.AssingedToLists = GetAssingedToList(obj.MantisId, obj.Slno); //Get the list of AssingedToList
                issueDetails.Add(obj);
            }

            dr.Close();
            con.Close();

            return(issueDetails);
        }