public static STD_CBEExamSubject GetCBEExamSubjectByID(int id)
 {
     STD_CBEExamSubject cBEExamSubject = new STD_CBEExamSubject();
     SqlCBEExamSubjectProvider sqlCBEExamSubjectProvider = new SqlCBEExamSubjectProvider();
     cBEExamSubject = sqlCBEExamSubjectProvider.GetCBEExamSubjectByID(id);
     return cBEExamSubject;
 }
    protected void btnAddSubjectDetaisl_OnClick(object sender, EventArgs e)
    {
        if (Session["examSubjects"] == null)
        {

            List<STD_CBEExamSubject> examSubjects = new List<STD_CBEExamSubject>();
            STD_CBEExamSubject examSubject = new STD_CBEExamSubject();

            examSubject.SubjectTitle = txtSubjectTitle.Text;
            examSubject.SubjectCode = txtSubjectCode.Text;
            examSubject.TaxOrPaperVariant = ddlTPV.SelectedItem.Text;
            examSubject.ExamDate = txtExamDate.Text != "" ? DateTime.Parse(txtExamDate.Text) : DateTime.Parse("1/1/1753");
            examSubject.AddedBy = Profile.card_id;
            examSubject.AddedDate = DateTime.Now;
            examSubject.UpdatedBy = Profile.card_id;
            examSubject.UpdatedDate = DateTime.Now;
            examSubject.Fees = txtFees.Text!=""?Convert.ToDecimal(txtFees.Text):0;
            examSubject.CBEExamSubjectID = examSubjects.Count;
            examSubjects.Add(examSubject);
            Session["examSubjects"] = examSubjects;
            gvCBEExamSubject.DataSource = Session["examSubjects"];
            gvCBEExamSubject.DataBind();

        }
        else
        {
            STD_CBEExamSubject examSubject = new STD_CBEExamSubject();
            examSubject.SubjectTitle = txtSubjectTitle.Text;
            examSubject.SubjectCode = txtSubjectCode.Text;
            examSubject.TaxOrPaperVariant = ddlTPV.SelectedItem.Text;
            examSubject.ExamDate = txtExamDate.Text != "" ? DateTime.Parse(txtExamDate.Text) : DateTime.Parse("1/1/1753");
            examSubject.Fees = txtFees.Text != "" ? Convert.ToDecimal(txtFees.Text) : 0;
            examSubject.AddedBy = Profile.card_id;
            examSubject.AddedDate = DateTime.Now;
            examSubject.UpdatedBy = Profile.card_id;
            examSubject.UpdatedDate = DateTime.Now;

            examSubject.CBEExamSubjectID = ((List<STD_CBEExamSubject>)Session["examSubjects"]).Count;

            ((List<STD_CBEExamSubject>)Session["examSubjects"]).Add(examSubject);

            gvCBEExamSubject.DataSource = Session["examSubjects"];
            gvCBEExamSubject.DataBind();
        }
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        try
        {
            STD_CBEExam cBEExam = new STD_CBEExam();

            cBEExam.CandidateName = txtCandidateName.Text;
            cBEExam.DOB =txtDOB.Text!=""? Convert.ToDateTime(txtDOB.Text):DateTime.Parse("1/1/1753");
            cBEExam.Gender = ddlGender.SelectedItem.Text ;
            cBEExam.RegiNo = txtRegiNo.Text;
            cBEExam.InstituteName = txtInstituteName.Text;
            cBEExam.Tel = txtTel.Text;
            cBEExam.Mobile = txtMobile.Text;
            cBEExam.Email = txtEmail.Text;
            cBEExam.FeesDescription = txtFeesDescription.Text;
            cBEExam.AddedBy = Profile.card_id;
            cBEExam.AddedDate = DateTime.Now;
            cBEExam.UpdatedBy = Profile.card_id;
            cBEExam.UpdatedDate = DateTime.Now;
            cBEExam.RowStatusID = 1;
            int resutl = STD_CBEExamManager.InsertCBEExam(cBEExam);
            if (resutl != null)
            {
                List<STD_CBEExamSubject> examSubjects = new List<STD_CBEExamSubject>();
                examSubjects = (List<STD_CBEExamSubject>)Session["examSubjects"];

                foreach (STD_CBEExamSubject es in examSubjects)
                {
                    STD_CBEExamSubject examSubject = new STD_CBEExamSubject();
                    examSubject.SubjectTitle = es.SubjectTitle;
                    examSubject.SubjectCode = es.SubjectCode;
                    examSubject.TaxOrPaperVariant = es.TaxOrPaperVariant;
                    examSubject.ExamDate = es.ExamDate;
                    examSubject.Fees = es.Fees;
                    examSubject.AddedBy = Profile.card_id;
                    examSubject.AddedDate = DateTime.Now;
                    examSubject.UpdatedBy = Profile.card_id;
                    examSubject.UpdatedDate = DateTime.Now;
                    examSubject.RowStatusID = 1;
                    examSubject.CBEExamID = resutl;

                    string sql = @"
        INSERT INTO [STD_CBEExamAcc]
           ([Head]
           ,[AccountFor]
           ,[Amount]
           ,[AddedDate]
           ,[AddedBy]
           ,[IsOpiningOrClosingAcc])
         VALUES
           ('Exam Fees','" + txtCandidateName.Text + (txtStudentCode.Text.Trim() == "" ? "" : "(" + txtStudentCode.Text + ")") + @"'
        ,"+es.Fees+",GETDATE(),'"+Profile.FirstName+@"',0);
        ";
                    CommonManager.SQLExec(sql);
                    int re = STD_CBEExamSubjectManager.InsertCBEExamSubject(examSubject);
                }
            }

            Session.Remove("examSubjects");
            Response.Redirect("MoneyReceipt.aspx?examID="+resutl);
        }

        catch (Exception ex)
        {
        }
    }
 public static bool UpdateCBEExamSubject(STD_CBEExamSubject cBEExamSubject)
 {
     SqlCBEExamSubjectProvider sqlCBEExamSubjectProvider = new SqlCBEExamSubjectProvider();
     return sqlCBEExamSubjectProvider.UpdateCBEExamSubject(cBEExamSubject);
 }
 public static int InsertCBEExamSubject(STD_CBEExamSubject cBEExamSubject)
 {
     SqlCBEExamSubjectProvider sqlCBEExamSubjectProvider = new SqlCBEExamSubjectProvider();
     return sqlCBEExamSubjectProvider.InsertCBEExamSubject(cBEExamSubject);
 }
    public STD_CBEExamSubject GetCBEExamSubjectFromReader(IDataReader reader)
    {
        try
        {
            STD_CBEExamSubject cBEExamSubject = new STD_CBEExamSubject
                (
                    (int)reader["ExamSubjectID"],
                    (int)reader["CBEExamID"],
                    reader["SubjectTitle"].ToString(),
                    reader["SubjectCode"].ToString(),
                    reader["TaxOrPaperVariant"].ToString(),
                    (Decimal)reader["Fees"],
                    (DateTime)reader["ExamDate"],
                    reader["AddedBy"].ToString(),
                    (DateTime)reader["AddedDate"],
                    reader["UpdatedBy"].ToString(),
                    (DateTime)reader["UpdatedDate"],
                    (int)reader["RowStatusID"]
                );

            try
            {
                cBEExamSubject.FeesDescription = reader["FeesDescription"].ToString();
            }
            catch (Exception ex)
            {
            }

             return cBEExamSubject;
        }
        catch(Exception ex)
        {
            return null;
        }
    }
    public bool UpdateCBEExamSubject(STD_CBEExamSubject cBEExamSubject)
    {
        using (SqlConnection connection = new SqlConnection(this.ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("Islamicfinancebd_CUCDB_UpdateCBEExamSubject", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@CBEExamSubjectID", SqlDbType.Int).Value = cBEExamSubject.CBEExamSubjectID;
            cmd.Parameters.Add("@CBEExamID", SqlDbType.Int).Value = cBEExamSubject.CBEExamID;
            cmd.Parameters.Add("@SubjectTitle", SqlDbType.NVarChar).Value = cBEExamSubject.SubjectTitle;
            cmd.Parameters.Add("@SubjectCode", SqlDbType.NVarChar).Value = cBEExamSubject.SubjectCode;
            cmd.Parameters.Add("@TaxOrPaperVariant", SqlDbType.NVarChar).Value = cBEExamSubject.TaxOrPaperVariant;
            cmd.Parameters.Add("@Fees", SqlDbType.Decimal).Value = cBEExamSubject.Fees;
            cmd.Parameters.Add("@ExamDate", SqlDbType.DateTime).Value = cBEExamSubject.ExamDate;
            cmd.Parameters.Add("@AddedBy", SqlDbType.UniqueIdentifier).Value = cBEExamSubject.AddedBy;
            cmd.Parameters.Add("@AddedDate", SqlDbType.DateTime).Value = cBEExamSubject.AddedDate;
            cmd.Parameters.Add("@UpdatedBy", SqlDbType.UniqueIdentifier).Value = cBEExamSubject.UpdatedBy;
            cmd.Parameters.Add("@UpdatedDate", SqlDbType.DateTime).Value = cBEExamSubject.UpdatedDate;
            cmd.Parameters.Add("@RowStatusID", SqlDbType.Int).Value = cBEExamSubject.RowStatusID;
            connection.Open();

            int result = cmd.ExecuteNonQuery();
            return result == 1;
        }
    }
    public int InsertCBEExamSubject(STD_CBEExamSubject cBEExamSubject)
    {
        using (SqlConnection connection = new SqlConnection(this.ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("InsertSTD_CBEExamSubject", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@ExamSubjectID", SqlDbType.Int).Direction = ParameterDirection.Output;
            cmd.Parameters.Add("@CBEExamID", SqlDbType.Int).Value = cBEExamSubject.CBEExamID;
            cmd.Parameters.Add("@SubjectTitle", SqlDbType.NVarChar).Value = cBEExamSubject.SubjectTitle;
            cmd.Parameters.Add("@SubjectCode", SqlDbType.NVarChar).Value = cBEExamSubject.SubjectCode;
            cmd.Parameters.Add("@TaxOrPaperVariant", SqlDbType.NVarChar).Value = cBEExamSubject.TaxOrPaperVariant;
            cmd.Parameters.Add("@Fees", SqlDbType.Decimal).Value = cBEExamSubject.Fees;
            cmd.Parameters.Add("@ExamDate", SqlDbType.DateTime).Value = cBEExamSubject.ExamDate;
            cmd.Parameters.Add("@AddedBy", SqlDbType.NVarChar).Value = cBEExamSubject.AddedBy;
            cmd.Parameters.Add("@AddedDate", SqlDbType.DateTime).Value = cBEExamSubject.AddedDate.AddHours(double.Parse(ConfigurationManager.AppSettings["ServerTimeDiff"].ToString()));
            cmd.Parameters.Add("@UpdatedBy", SqlDbType.NVarChar).Value = cBEExamSubject.UpdatedBy;
            cmd.Parameters.Add("@UpdatedDate", SqlDbType.DateTime).Value = cBEExamSubject.UpdatedDate.AddHours(double.Parse(ConfigurationManager.AppSettings["ServerTimeDiff"].ToString()));
            cmd.Parameters.Add("@RowStatusID", SqlDbType.Int).Value = cBEExamSubject.RowStatusID;
            connection.Open();

            int result = cmd.ExecuteNonQuery();
            return (int)cmd.Parameters["@ExamSubjectID"].Value;
        }
    }