protected void insertRebateData(object sender, EventArgs e)
        {
            RebateDAO rebateDAO = new RebateDAO();
            Rebate rebate = new Rebate();

            rebate.idMember = this.ID_SELECTED_MEMBER.Text;
            rebate.idPartner = this.ID_SELECTED_PARTNER.Text;
            rebate.year = this.selectedYear.Text + "-01-01";
            rebate.type = this.selectedCategory.Text;
            rebate.quantity = this.selectedAmount.Text;
            if(this.selectedDeliveredByPartner.Text.Equals("Partner")){
                rebate.isDeliveredByPartner = true;
            }
            else
            {
                rebate.isDeliveredByPartner = false;
            }
            rebate.dateModified = System.DateTime.Today.ToShortDateString();
            rebate.modifiedBy = Page.User.Identity.Name;

            string result = rebateDAO.insertSingleRebateData(rebate);

            this.mainForm.Visible = false;
            this.response.Visible = true;
            this.responseText.Text = result;
        }
Example #2
0
        public string insertSingleRebateData(Rebate rebate)
        {
            string conn = ConfigurationManager.ConnectionStrings["Conn"].ToString();
            SqlConnection sqlConn = new SqlConnection();
            sqlConn.ConnectionString = conn;

            SqlCommand cmd = new SqlCommand(string.Format(
            @"INSERT INTO REBATE (ID_MEMBER, ID_PARTNER, IS_DELiVERED_BY_PARTNER, QUANTITY, CATEGORY, YEAR, DATE_MODIFIED, MODIFIED_BY)
            VALUES (@ID_MEMBER, @ID_PARTNER, @IS_DELiVERED_BY_PARTNER, @QUANTITY, @CATEGORY, @YEAR, @DATE_MODIFIED, @MODIFIED_BY)"), sqlConn);

            cmd.Parameters.AddWithValue("@ID_MEMBER", rebate.idMember);
            cmd.Parameters.AddWithValue("@ID_PARTNER", rebate.idPartner);
            cmd.Parameters.AddWithValue("@IS_DELiVERED_BY_PARTNER", rebate.isDeliveredByPartner);
            cmd.Parameters.AddWithValue("@QUANTITY", rebate.quantity);
            cmd.Parameters.AddWithValue("@CATEGORY", rebate.type);
            cmd.Parameters.AddWithValue("@YEAR", rebate.year);
            cmd.Parameters.AddWithValue("@DATE_MODIFIED", rebate.dateModified);
            cmd.Parameters.AddWithValue("@MODIFIED_BY", rebate.modifiedBy);

            try
            {
                sqlConn.Open();
                cmd.ExecuteNonQuery();
                return "The Rebate data was inserted into the database successfully.";
            }
            catch (Exception e)
            {
                return "error";
            }
            finally
            {
                sqlConn.Close();
            }
        }