示例#1
0
        protected void btnsubmitoffers_Click(object sender, EventArgs e)
        {
            DAC_BookServices oDAC_BookServices = new DAC_BookServices();
            REF_BookServices oREF_BookServices = new REF_BookServices();

            oREF_BookServices.CusID     = Convert.ToInt32(dropCusotmer.Value);
            oREF_BookServices.ServiceID = Convert.ToInt32(dropService.Value);
            oREF_BookServices.OfferID   = Convert.ToInt32(dropoffers.Value);
            DataTable  dt;
            DAV_Offers oDAV_Offers = new DAV_Offers();
            REF_Offers oREF_Offers = new REF_Offers();

            oREF_Offers.ID = Convert.ToInt32(dropoffers.Value);
            dt             = oDAV_Offers.SelectOffersByID(oREF_Offers);
            Double OfferPrice = Double.Parse(dt.Rows[0][6].ToString());

            oREF_BookServices.OfferPrice = dt.Rows[0][6].ToString();

            DAC_Service oDAC_Service = new DAC_Service();
            REF_Service oREF_Service = new REF_Service();

            oREF_Service.ID = Convert.ToInt32(dropService.Value);
            dt = oDAC_Service.SelectServiceByID(oREF_Service);
            Double ServicePrice = Double.Parse(dt.Rows[0][4].ToString());

            Double Total = ServicePrice - OfferPrice;

            oREF_BookServices.ServicePrice = dt.Rows[0][3].ToString();

            oREF_BookServices.TotalPrice = Total.ToString();
            oDAC_BookServices.Insert(oREF_BookServices);
            LoadData();
        }
示例#2
0
        public void Insert(REF_BookServices oREF_BookServices)
        {
            DBConnecton db;

            db = new DBConnecton();
            string     sqlQuery;
            SqlCommand oSqlCommand;

            try

            {
                sqlQuery = "INSERT INTO `tblbookservice` (`ID`, `CusID`, `ServiceID`, `Status`, `OfferID`, `ServicePrice`, `OfferPrice`, `TotalPrice`)" +
                           "VALUES (NULL, '" + oREF_BookServices.CusID + "', '" + oREF_BookServices.ServiceID + "', '0', '" + oREF_BookServices.OfferID + "', '" + oREF_BookServices.ServicePrice + "', '" + oREF_BookServices.OfferPrice + "', '" + oREF_BookServices.TotalPrice + "');";

                //open connection
                if (db.OpenConnection() == true)
                {
                    //create command and assign the query and connection from the constructor
                    MySqlCommand cmd = new MySqlCommand(sqlQuery, db.getConnetion());

                    //Execute command
                    cmd.ExecuteNonQuery();

                    //close connection
                    db.CloseConnection();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }