public Results<string> creatSoftReq(softwareInfo rn,upgrade up)
        {
            Results<string> result = new Results<string>();
            try
            {
                HelperData h = new HelperData();
                rn.userCode = Convert.ToInt16(System.Web.HttpContext.Current.Session["userCode"]);
                rn.deleted = false;
                up.deleted = false;
                Int16 t = h.AddSoftwareInfo(rn);
                if (t != 0)
                {
                    result.IsSuccessfull = true;
                    up.softwareCode = rn.softwareCode;
                    h.AddUpgrade(up);

                }
            }
            catch (Exception error)
            {
                result.IsSuccessfull = false;
                result.Message = error.Message;
            }
            return result;
        }
 public static string updateSoftReq(softwareInfo rn)
 {
     AddSoftwareBLL asb = new AddSoftwareBLL();
     return JsonConvert.SerializeObject(asb.updateSoftReq(rn));
 }
 public static string creatSoftUpgradeReq(softwareInfo rn,upgrade up)
 {
     AddSoftwareBLL asb = new AddSoftwareBLL();
     return JsonConvert.SerializeObject(asb.creatSoftReq(rn,up));
 }
        public softwareInfo Detailsoftware(Int16 softwareCode)
        {
            try{
                var v = from i in db.softwareInfos
                        where i.softwareCode == softwareCode
                        select i;
                softwareInfo newsoftware = v.FirstOrDefault();
                return newsoftware;

            }
            catch (Exception error)
            {
                softwareInfo newsoft = new softwareInfo();
                newsoft.softwareCode = -1;
                return newsoft;
            }
        }
 //Add To SoftwareInfo Table
 public Int16 AddSoftwareInfo(softwareInfo si)
 {
     try
     {
         db.softwareInfos.InsertOnSubmit(si);
         db.SubmitChanges();
         return si.softwareCode;
     }
     catch (Exception error)
     {
         return 0;
     }
 }
        //Edit SoftwareInfo Table
        public int EditSoftwareInfo(softwareInfo si)
        {
            try
            {
                var v = from i in db.softwareInfos
                        where i.softwareCode == si.softwareCode
                        select i;
                softwareInfo newsoftware = v.FirstOrDefault();
                if(newsoftware != null)
                {
                    newsoftware.softwareCode = si.softwareCode;
                    newsoftware.languageCode = si.languageCode;
                    newsoftware.memariCode = si.memariCode;
                    newsoftware.dbCode = si.dbCode;
                    newsoftware.cityInUse = si.cityInUse;
                    newsoftware.softwareName = si.softwareName;
                    newsoftware.serverLocation = si.serverLocation;
                    newsoftware.companyName = si.companyName;
                    newsoftware.softwarePrice = si.softwarePrice;
                    newsoftware.isSupport = si.isSupport;
                    newsoftware.endDateSupport = si.endDateSupport;
                    newsoftware.supportPrice = si.supportPrice;
                    newsoftware.isUsed = si.isUsed;
                    newsoftware.instalationDate = si.instalationDate;
                    newsoftware.contractNumber = si.contractNumber;
                    newsoftware.supportPeriodNumber = si.supportPeriodNumber;
                    newsoftware.supportPeriodType = si.supportPeriodType;
                    newsoftware.isHardwareLock = si.isHardwareLock;
                    newsoftware.isSource = si.isSource;
                    newsoftware.description = si.description;
                    newsoftware.lastDbVersion = si.lastDbVersion;
                    newsoftware.supervisorName = si.supervisorName;
                    newsoftware.supervisorTell = si.supervisorTell;
                    newsoftware.companyNamayandeName = si.companyNamayandeName;
                    newsoftware.supportTell = si.supportTell;
                    newsoftware.isReportCreate = si.isReportCreate;
                    newsoftware.isFixReport = si.isFixReport;
                    newsoftware.userCount = si.userCount;
                    newsoftware.isDocument = si.isDocument;
                    newsoftware.softwareProblem = si.softwareProblem;
                    newsoftware.isPatchUpdate = si.isPatchUpdate;
                    newsoftware.isFtpUpdate = si.isFtpUpdate;
                    newsoftware.isDirectAccessUpdate = si.isDirectAccessUpdate;
                    newsoftware.isOtherUpdate = si.isOtherUpdate;
                    newsoftware.isOpBuyer = si.isOpBuyer;
                    newsoftware.userCode = si.userCode;
                    newsoftware.deleted = false;
                    newsoftware.vahedCode = si.vahedCode;
                    newsoftware.zoneCode = si.zoneCode;
                    newsoftware.isAllVahed = si.isAllVahed;
                    newsoftware.companyTell = si.companyTell;
                    newsoftware.companyAddress = si.companyAddress;
                    newsoftware.subject = si.subject;

                    db.SubmitChanges();
                    return 1;
                } return 0;//not found
            }
            catch (Exception error)
            {
                return -1;
            }
        }
		private void detach_softwareInfos(softwareInfo entity)
		{
			this.SendPropertyChanging();
			entity.DB = null;
		}
		private void attach_softwareInfos(softwareInfo entity)
		{
			this.SendPropertyChanging();
			entity.DB = this;
		}
 partial void DeletesoftwareInfo(softwareInfo instance);
 partial void UpdatesoftwareInfo(softwareInfo instance);
 partial void InsertsoftwareInfo(softwareInfo instance);
		private void detach_softwareInfos(softwareInfo entity)
		{
			this.SendPropertyChanging();
			entity.programLanguage = null;
		}
        //Add To SoftwareInfo Table
        public Int16 AddSoftwareInfo(softwareInfo si)
        {
            try
            {
                db.softwareInfos.InsertOnSubmit(si);
                db.SubmitChanges();
                if (si.vahedCode != 0)
                {
                    si.softCodeDefine = (si.vahedCode).ToString() + (si.zoneCode).ToString() + (si.softwareCode).ToString();
                }
                else
                    si.softCodeDefine = "0" + (si.zoneCode).ToString() + (si.softwareCode).ToString();
                return si.softwareCode;
            }

            catch (Exception error)
            {
                return 0;
            }
        }
        public object updateSoftReq(softwareInfo rn)
        {
            Results<string> result = new Results<string>();
            try
            {
                HelperData h = new HelperData();
                rn.deleted = false;
                rn.userCode = Convert.ToInt16(System.Web.HttpContext.Current.Session["userCode"]);

                int t = h.EditSoftwareInfo(rn);
                if (t != 0)
                {
                    result.IsSuccessfull = true;
                  //  result.Value = rn.softwareCode.ToString();
                }
            }
            catch (Exception error)
            {
                result.IsSuccessfull = false;
                result.Message = error.Message;
            }
            return result;
        }