Exemple #1
0
 public void AddPaperDetail(PaperMaster obj)
 {
     try
     {
         SqlParameter[] parameter = new SqlParameter[]
         {
             new SqlParameter("@SubjectID", obj.SubjectId),
             //new SqlParameter("@TopicID",obj.TopicID),
             new SqlParameter("@GradeID", obj.GradeID),
             new SqlParameter("@IsYearwise", obj.IsYearwise),
             new SqlParameter("@Year", obj.Year),
             new SqlParameter("@Month", obj.Month),
             new SqlParameter("@IsSample", obj.IsSample),
             new SqlParameter("@Name", obj.Name),
             // new SqlParameter("@IsVisible",obj.IsVisible.Equals(true)?1:0),
             new SqlParameter("@Description", obj.Description),
             new SqlParameter("@DiscountID", obj.DiscountID),
             new SqlParameter("@Price", obj.Price),
             new SqlParameter("@BaseCurrency", obj.BaseCurrency),
             new SqlParameter("@ValidFrom", obj.ValidFrom),
             new SqlParameter("@ValidUpto", obj.ValidUpto),
             new SqlParameter("@CreatedBy", obj.CreatedBy),
             new SqlParameter("@UpdatedBy", obj.UpdatedBy)
         };
         DBOperate.ExecuteProcedureWithOutReturn("usp_AddPaper", parameter);
     }
     catch
     {
         throw;
     }
 }
Exemple #2
0
        protected void btnAddPaper_Click(object sender, EventArgs e)
        {
            DateTime dt, dt1;

            //   System.Threading.Thread.Sleep(5000);
            obj             = new PaperMaster();
            obj.Name        = txtName.Text;
            obj.Description = txtDescription.Text;
            obj.SubjectId   = Convert.ToInt16(ddlSubject.SelectedValue);
            //obj.TopicID = Convert.ToInt16(ddlTopic.SelectedValue);
            obj.GradeID    = 0;
            obj.Year       = Convert.ToInt16(txtYear.Text);
            obj.Month      = Convert.ToInt16(txtMonth.Text);
            obj.IsYearwise = chkYearwise.Checked == true ? 1 : 0;
            obj.IsSample   = chkSample.Checked == true ? 1 : 0;
            //obj.IsVisible = chkVisible.Checked;
            obj.CreatedBy = 1;
            obj.UpdatedBy = 1;
            obj.PaperID   = Convert.ToInt16(lblPaperID.Text);

            if (chkSample.Checked && Convert.ToDouble("0" + txtPrice.Text) > 0)
            {
                msgbox("For Sample paper Price should be 0");
                return;
            }

            if (!chkSample.Checked && Convert.ToDouble("0" + txtPrice.Text) <= 0)
            {
                msgbox("For Non-Sample paper Price should be greater than 0");
                return;
            }

            if (chkSample.Checked)
            {
                obj.Price = 0.00;
            }
            else
            {
                obj.Price = Convert.ToDouble("0" + txtPrice.Text);
            }
            obj.BaseCurrency = ddlCurrency.SelectedValue;
            obj.DiscountID   = Convert.ToInt16(ddlDiscount.SelectedValue);
            if (DateTime.TryParseExact(txtValidFrom.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt))
            {
                obj.ValidFrom = dt;
            }
            else
            {
                msgbox("Invalid ValidFrom Date");
                return;
            }
            if (DateTime.TryParseExact(txtValidTo.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt1))
            {
                obj.ValidUpto = dt1;
            }
            else
            {
                msgbox("Invalid ValidTo Date");
                return;
            }

            if (dt.Date > dt1.Date)
            {
                msgbox("ValidFrom date should be less than ValidTo date");
                return;
            }

            if (lblPaperID.Text.Equals("-1"))
            {
                obj1 = new PaperMasterDataManager();
                obj1.AddPaperDetail(obj);
                msgbox("Paper Added successfully!!!");
            }
            else
            {
                obj1 = new PaperMasterDataManager();
                obj1.UpdatePaperDetail(obj);
                msgbox("Paper updated successfully!!!");
            }
            Clear();
            BindDropdown();
            bind(ddlSubject.SelectedValue);
        }