Ejemplo n.º 1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                YearForecastBEL objBEL = new YearForecastBEL();
                for (int i = 0; i < dgCustomerDatai1.Items.Count; i++)
                {
                    DataGridCell cell0      = FunctionClass.GetCell(dgCustomerDatai1, i, 0);
                    DataGridCell cell2      = FunctionClass.GetCell(dgCustomerDatai1, i, 2);
                    TextBlock    tb0        = cell0.Content as TextBlock;
                    TextBlock    tb1        = cell2.Content as TextBlock;
                    string       customerId = tb0.Text.Trim();
                    string       forecast   = tb1.Text.Trim() == "" ? "0" : tb1.Text.Trim();
                    objBEL.CustomerId = tb0.Text.Trim();
                    objBEL.Forecast   = Convert.ToDecimal(tb1.Text.Trim());
                    objBEL.Year       = cbYear.SelectedValue.ToString();
                    YearForecastBLL.insertCustomer(objBEL);
                }

                System.Windows.Forms.MessageBox.Show("設定完畢", "Message");
            }
            catch
            {
            }
        }
Ejemplo n.º 2
0
        public static Int32 insertCustomer(YearForecastBEL objBel)
        {
            YearForecastDAL objDal = new YearForecastDAL();

            try
            {
                return(objDal.insertYearForecast(objBel));
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                objDal = null;
            }
        }
Ejemplo n.º 3
0
        public Int32 insertYearForecast(YearForecastBEL objBEL)
        {
            int result;

            try
            {
                SqlCommand cmd = new SqlCommand("dbo.sp_insertYearForecast", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@CustomerId", objBEL.CustomerId);
                cmd.Parameters.AddWithValue("@Year", objBEL.Year);
                cmd.Parameters.AddWithValue("@Forecast", objBEL.Forecast);

                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                result = cmd.ExecuteNonQuery();
                cmd.Dispose();
                if (result > 0)
                {
                    return(result);
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (con.State != ConnectionState.Closed)
                {
                    con.Close();
                }
            }
        }