コード例 #1
0
        public static ObjectValidation Validate(ATTSponsor objSponsor)
        {
            ObjectValidation OV = new ObjectValidation();

            if (objSponsor.SponsorName == "")
            {
                OV.IsValid      = false;
                OV.ErrorMessage = "Sponsor Name Cannot be Blank.";
                return(OV);
            }
            return(OV);
        }
コード例 #2
0
 public static bool AddProgram(ATTSponsor objSponsor)
 {
     try
     {
         DLLSponsor.AddSponsor(objSponsor);
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #3
0
        public static List <ATTSponsor> GetSponsorList(int sponsorID, string containDefaultValue)
        {
            List <ATTSponsor> SponsorLST = new List <ATTSponsor>();

            foreach (DataRow row in DLLSponsor.GetSponsorTable(sponsorID).Rows)
            {
                ATTSponsor objSponsor = new ATTSponsor
                                        (
                    int.Parse(row["SPONSOR_ID"].ToString()),
                    row["SPONSOR_Name"].ToString(),
                    "A"
                                        );

                SponsorLST.Add(objSponsor);
            }
            if (containDefaultValue == "Y")
            {
                SponsorLST.Insert(0, new ATTSponsor(0, "--- Select Sponsor ---", ""));
            }

            return(SponsorLST);
        }
        public static bool AddSponsor(ATTSponsor objSponsor)
        {
            string InsertUpdateSP = "";

            if (objSponsor.Action == "A")
            {
                InsertUpdateSP = "SP_ADD_SPONSOR";
            }
            else if (objSponsor.Action == "E")
            {
                InsertUpdateSP = "SP_EDIT_SPONSOR";
            }


            OracleParameter[] paramArray = new OracleParameter[2];
            paramArray[0] = Utilities.GetOraParam(":p_SPONSOR_ID", objSponsor.SponsorID, OracleDbType.Int64, ParameterDirection.InputOutput);
            paramArray[1] = Utilities.GetOraParam(":p_SPONSOR_NAME", objSponsor.SponsorName, OracleDbType.Varchar2, ParameterDirection.Input);

            GetConnection GetConn = new GetConnection();

            try
            {
                OracleConnection DBConn = GetConn.GetDbConn(Module.DLPDS);

                SqlHelper.ExecuteNonQuery(DBConn, CommandType.StoredProcedure, InsertUpdateSP, paramArray);
                if (objSponsor.Action == "A")
                {
                    objSponsor.SponsorID = int.Parse(paramArray[0].Value.ToString());
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #5
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        List <ATTSponsor> SponsorLST = (List <ATTSponsor>)Session["Sponsors"];
        ATTSponsor        obj        = new ATTSponsor();

        if (lstSponsors.SelectedIndex == -1)
        {
            obj = SponsorLST.Find
                  (
                delegate(ATTSponsor objSp)
            {
                return(objSp.SponsorName.ToLower() == this.txtSponsorName_RQD.Text.ToLower());
            }
                  );

            if (obj != null)
            {
                this.lblStatusMessage.Text = "Sponsor Name Already Exists";
                this.programmaticModalPopup.Show();
                return;
            }
        }
        //else
        //{
        //    obj = SponsorLST.Find
        //                         (
        //                            delegate(ATTSponsor objSp)
        //                            {
        //                                return objSp.SponsorName.ToLower() == this.txtSponsorName_RQD.Text.ToLower() && objSp.SponsorID!=int.Parse(lstSponsors.SelectedValue);
        //                            }
        //                          );

        //}



        ATTSponsor objSponsor = new ATTSponsor(
            (lstSponsors.SelectedIndex == -1) ? 0 : int.Parse(lstSponsors.SelectedValue),
            this.txtSponsorName_RQD.Text.Trim(),
            (lstSponsors.SelectedIndex == -1) ? "A" : "E");

        ObjectValidation OV = BLLSponsor.Validate(objSponsor);

        if (OV.IsValid == false)
        {
            this.lblStatusMessage.Text = OV.ErrorMessage;
            this.programmaticModalPopup.Show();
            return;
        }

        if (BLLSponsor.AddProgram(objSponsor) == true)
        {
            if (lstSponsors.SelectedIndex == -1)
            {
                SponsorLST.Add(objSponsor);
            }
            else
            {
                SponsorLST[lstSponsors.SelectedIndex].SponsorName = this.txtSponsorName_RQD.Text.Trim();
            }
        }

        lstSponsors.DataSource     = SponsorLST;
        lstSponsors.DataTextField  = "SponsorName";
        lstSponsors.DataValueField = "SponsorID";
        lstSponsors.DataBind();

        clearAll();
    }