Exemplo n.º 1
0
        // Insertion
        public ActionResult SaveRecord(String ps_Code, String Location, String Title)
        {
            Int32 li_ReturnValue = 0;

            try
            {
                    SETUP_CodeAnalysis2 lrow_CodeAnalysis2 = new SETUP_CodeAnalysis2();

                    if (String.IsNullOrEmpty(ps_Code))
                    {
                        if (DALCommon.AutoCodeGeneration("SETUP_CodeAnalysis2") == 1)
                        {
                            ps_Code = DALCommon.GetMaximumCode("SETUP_CodeAnalysis2");
                        }
                    }

                    if (!String.IsNullOrEmpty(ps_Code))
                    {
                        lrow_CodeAnalysis2.CA_Id = ps_Code;
                        lrow_CodeAnalysis2.CA_Code = ps_Code;
                        lrow_CodeAnalysis2.CA_Title = Title;
                        lrow_CodeAnalysis2.Loc_Id = Location;
                        lrow_CodeAnalysis2.CA_Active = 1;

                        li_ReturnValue = objDALCodeAnalysis2.SaveRecord(lrow_CodeAnalysis2);
                        ViewData["SaveResult"] = li_ReturnValue;
                    }

                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }
Exemplo n.º 2
0
        public int SaveRecord(SETUP_CodeAnalysis2 lrow_CodeAnalysis2)
        {
            int li_ReturnValue = 0;

            try
            {
                SCMSDataContext dbSCMS = Connection.Create();

                SETUP_CodeAnalysis2 lRow_ExistingData = dbSCMS.SETUP_CodeAnalysis2s.Where(c => c.CA_Id.Equals(lrow_CodeAnalysis2.CA_Id)).SingleOrDefault();
                if (lRow_ExistingData != null)
                {
                    lRow_ExistingData.CA_Title = lrow_CodeAnalysis2.CA_Title;
                    lRow_ExistingData.Loc_Id = lrow_CodeAnalysis2.Loc_Id;
                }
                else
                {
                    dbSCMS.SETUP_CodeAnalysis2s.InsertOnSubmit(lrow_CodeAnalysis2);
                }
                dbSCMS.SubmitChanges();

                li_ReturnValue = Convert.ToInt32(lrow_CodeAnalysis2.CA_Id);
            }
            catch
            {
                return 0;
            }

            return li_ReturnValue;
        }