コード例 #1
0
 public static Activity Save(Activity myActivity)
 {
     //objLead.InsertBy = Convert.ToInt32(HttpContext.Current.User.Identity.Name);
     if (myActivity.ActivityID == 0)
     {
         DbContextHelper.DbContext.Add(myActivity);
         //claimRulerDBContext.Activity.Add(myActivity);
     }
     DbContextHelper.DbContext.SaveChanges();
     //claimRulerDBContext.SaveChanges();
     return myActivity;
 }
コード例 #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int clientID = Core.SessionHelper.getClientId();

            lblError.Text = string.Empty;
            lblError.Visible = false;
            lblSave.Text = string.Empty;
            lblSave.Visible = false;
            lblMessage.Visible = false;
            lblMessage.Text = string.Empty;
            Activity myActivity = null;

            int id = 0;
            id = Convert.ToInt32(Session["ActivityID"]);

            //bool exists = ProducerManager.IsExist(txtProducer.Text.Trim(), clientID);

            //if (exists) {
            //    lblMessage.Text = "Primary Producer Name already exists.";
            //    lblMessage.Visible = true;
            //    txtProducer.Focus();
            //    return;
            //}

            try {
                using (TransactionScope scope = new TransactionScope()) {

                        if (id == 0)
                        {
                            myActivity = new Activity();
                        }
                        else
                        {
                            myActivity = ActivityManager.GetActivityById(id);
                        }
                        myActivity.Activity1 = txtActivity.Text;

                        ActivityManager.Save(myActivity);

                    //ProducerMaster producer = ProducerManager.GetProducerId(Convert.ToInt32(hdId.Value));
                    //producer.ProducerName = txtProducer.Text;
                    //producer.Status = 1;

                    // tortega 2013-08-09
                    //producer.ClientId = clientID;

                    //ProducerManager.Save(producer);
                     clearFields();
                    lblSave.Text = id == 0 ? "Record Saved Successfully." : "Record Updated Successfully.";
                    lblSave.Visible = true;
                    scope.Complete();
                }

                pnlEdit.Visible = false;

            }
            catch (Exception ex) {
                lblError.Visible = true;
                lblError.Text = "Record Not Saved !!!";

                Core.EmailHelper.emailError(ex);
            }
        }