Example #1
0
        public GeneralAgreement GetGAByID(int?id)
        {
            SamajkalyanEntities ent    = new SamajkalyanEntities();
            GeneralAgreement    entity = ent.GeneralAgreements.Where(x => x.GeneralAgreement_ID == id).FirstOrDefault();

            return(entity);
        }
Example #2
0
        public ActionResult Index(int id)
        {
            GeneralAgreement model = new GeneralAgreement();

            model = pro.GetGAByID(id);
            return(View(model));
        }
Example #3
0
        public bool InsertGeneralAgreement(GeneralAgreementViewModel model)
        {
            using (SamajkalyanEntities ent = new SamajkalyanEntities())
            {
                var GAEntity = new GeneralAgreement()
                {
                    // Ethnic_ID = model.Ethnic_ID,
                    Name_Of_Ingo        = model.Name_Of_Ingo,
                    Name_of_Ingo_Nepali = model.Name_of_Ingo_Nepali,
                    Ga_Date             = model.Ga_Date,
                    Ga_Date_Nepali      = model.Ga_Date_Nepali,
                    Period = model.Period,
                    Pre_Annum_Commitment_Amount = model.Pre_Annum_Commitment_Amount,
                    Ga_Service_Charge           = model.Ga_Service_Charge,
                    Sector         = model.Sector,
                    Hq_Address     = model.Hq_Address,
                    Contact_Person = model.Contact_Person,
                    Country_Official_Nepal_Address = model.Country_Official_Nepal_Address,
                    Contact_Number            = model.Contact_Number,
                    Email                     = model.Email,
                    GA_TerminationDate        = model.GA_TerminationDate,
                    Ga_TerminationDate_Nepali = model.Ga_TerminationDate_Nepali,
                    PA_Attachment_Location    = model.PA_Attachment_Location,
                    Scan_GA_Location          = model.Scan_GA_Location,


                    CreatedBy   = model.CreatedBy,
                    DeletedBy   = model.DeletedBy,
                    UpdatedBy   = model.UpdatedBy,
                    UpdatedDate = model.UpdatedDate,

                    CreatedDate = DateTime.Now,
                };
                ent.GeneralAgreements.Add(GAEntity);
                int i = ent.SaveChanges();



                if (i > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Example #4
0
        public bool InsertGeneralAgreement2(GeneralAgreementViewModel model)
        {
            using (SamajkalyanEntities ent = new SamajkalyanEntities())
            {
                try
                {
                    var generalAgreementRow = ent.GeneralAgreements.Where(x => x.GeneralAgreement_ID == model.GeneralAgreement_ID).FirstOrDefault();
                    //_context.Database.Connection.Open();
                    //_context.Database.Connection.BeginTransaction();
                    if (generalAgreementRow == null)
                    {
                        generalAgreementRow = new  GeneralAgreement();
                    }
                    ;
                    generalAgreementRow.Name_Of_Ingo        = model.Name_Of_Ingo;
                    generalAgreementRow.Name_of_Ingo_Nepali = model.Name_of_Ingo_Nepali;
                    generalAgreementRow.Ga_Date             = model.Ga_Date;
                    generalAgreementRow.Ga_Date_Nepali      = model.Ga_Date_Nepali;
                    generalAgreementRow.Period = model.Period;
                    generalAgreementRow.Pre_Annum_Commitment_Amount = model.Pre_Annum_Commitment_Amount;
                    generalAgreementRow.Ga_Service_Charge           = model.Ga_Service_Charge;
                    generalAgreementRow.Sector         = model.Sector;
                    generalAgreementRow.Hq_Address     = model.Hq_Address;
                    generalAgreementRow.Contact_Person = model.Contact_Person;
                    generalAgreementRow.Country_Official_Nepal_Address = model.Country_Official_Nepal_Address;
                    generalAgreementRow.Contact_Number            = model.Contact_Number;
                    generalAgreementRow.Email                     = model.Email;
                    generalAgreementRow.GA_TerminationDate        = model.GA_TerminationDate;
                    generalAgreementRow.Ga_TerminationDate_Nepali = model.Ga_TerminationDate_Nepali;
                    generalAgreementRow.Scan_GA_Location          = model.Scan_GA_Location;
                    generalAgreementRow.PA_Attachment_Location    = model.PA_Attachment_Location;
                    generalAgreementRow.Country                   = model.Country;

                    //deploymentRow.Status = true;
                    if (model.GeneralAgreement_ID == 0)
                    {
                        // generalAgreementRow.Status = false;
                        ent.GeneralAgreements.Add(generalAgreementRow);
                        ent.SaveChanges();
                    }
                    else
                    {
                        // deploymentRow.Status = dmodel.Status ?? false;
                        ent.GeneralAgreements.Attach(generalAgreementRow);
                        ent.Entry(generalAgreementRow).State = EntityState.Modified;
                        ent.SaveChanges();
                    }
                    if (model.GeneralAgreement_ID <= 0)
                    {
                        model.GeneralAgreement_ID = ent.Database.SqlQuery <GeneralAgreementViewModel>("select * from GeneralAgreement where GeneralAgreement_ID=(select max (GeneralAgreement_ID) from GeneralAgreement )").ToList().FirstOrDefault().GeneralAgreement_ID;
                        //employeeRow.EmpId=employeeRow.EmpId != 0 ? employeeRow.EmpId : empModel.EmpId;
                    }
                    //            #region files

                    //            using (var tempContext = new SamajkalyanEntities())
                    //            {
                    //                var deletelist = tempContext.GA_Attachment.Where(x => x.GeneralAgreement_ID == model.GeneralAgreement_ID).ToList();
                    //                if (deletelist.Count > 0)
                    //                {
                    //                    foreach (var item in deletelist)
                    //                    {
                    //                        if (model.GaAttachmentViewModelList == null)
                    //                        {
                    //                            model.GaAttachmentViewModelList = new List<GaAttachmentViewModel>();
                    //                        }
                    //                        var isExists = model.GaAttachmentViewModelList.Where(x => x.GA_Attachment_ID == item.GeneralAgreement_ID).FirstOrDefault();
                    //                        if (isExists == null)
                    //                        {
                    //                            tempContext.GA_Attachment.Remove(item);
                    //                            tempContext.SaveChanges();
                    //                        }
                    //                    }

                    //                }
                    //            }

                    //            if (model.GaAttachmentViewModelList != null)
                    //            {
                    //                foreach (var item in model.GaAttachmentViewModelList)
                    //                {
                    //                    GA_Attachment newRow = new GA_Attachment();
                    //                    newRow.GeneralAgreement_ID = model.GeneralAgreement_ID;
                    //                    newRow.GA_Attachment_ID = item.GA_Attachment_ID;
                    //                    newRow.PA_Attachment_Location = item.PA_Attachment_Location;
                    //                    newRow.Scan_GA_Location = item.Scan_GA_Location;
                    //                    //newRow.NoOfDep = item.NoOfDep;

                    //                    if (item.GA_Attachment_ID == 0)
                    //                    {
                    //                        ent.GA_Attachment.Add(newRow);
                    //                        ent.SaveChanges();
                    //                    }
                    //                    else
                    //                    {
                    //                        ent.GA_Attachment.Attach(newRow);
                    //                        ent.Entry(newRow).State = EntityState.Modified;
                    //                        ent.SaveChanges();
                    //                    }
                    //                }
                    //            }
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }

            return(true);
        }