Example #1
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     lblError.Text      = string.Empty;
     lblError.Visible   = false;
     lblSave.Text       = string.Empty;
     lblSave.Visible    = false;
     lblMessage.Visible = false;
     lblMessage.Text    = string.Empty;
     try {
         bool exists = OtherSourceManager.IsExist(txtOtherSource.Text.Trim(), Convert.ToInt32(hdId.Value));
         if (exists)
         {
             lblMessage.Text    = "Other Source allready exists.";
             lblMessage.Visible = true;
             txtOtherSource.Focus();
             return;
         }
         OtherSourceMaster obj = OtherSourceManager.GetbyOtherSourceId(Convert.ToInt32(hdId.Value));
         obj.OtherSource = txtOtherSource.Text;
         obj.Status      = true;
         OtherSourceManager.Save(obj);
         saveMsg = hdId.Value == "0" ? "Record Saved Sucessfully." : "Record Updated Sucessfully.";
         btnCancel_Click(null, null);
         lblSave.Text    = saveMsg;
         lblSave.Visible = true;
     }
     catch (Exception ex) {
         lblError.Visible = true;
         lblError.Text    = "Record Not Saved !!!";
     }
 }
        public static OtherSourceMaster Save(OtherSourceMaster objOtherSourceMaster)
        {
            if (objOtherSourceMaster.OtherSourceId == 0)
            {
                //objProducer.InsertBy = Convert.ToInt32(HttpContext.Current.User.Identity.Name);
                objOtherSourceMaster.InsertDate        = DateTime.Now;
                objOtherSourceMaster.InsertMachineInfo = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
                DbContextHelper.DbContext.Add(objOtherSourceMaster);
            }

            //secUser.UpdatedBy = Convert.ToInt32(HttpContext.Current.User.Identity.Name);
            objOtherSourceMaster.UpdateMachineIfo = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
            objOtherSourceMaster.UpdateDate       = DateTime.Now;
            DbContextHelper.DbContext.SaveChanges();

            return(objOtherSourceMaster);
        }