public ActionResult Create([Bind(Include = "IssueID,IssuedDate,ReturnDate,BookID,EmployeeID,MemberID")] Issued issued)
        {
            var books = db.Books.ToList();
            var issId = issued.BookID;
            var book1 = db.Books.First(b => b.BookID == issId);


            if (ModelState.IsValid)
            {
                if ((!issued.ReturnDate.HasValue) && (book1.Quantity > 0))
                {
                    book1.Quantity--;
                    db.SaveChanges();
                }
                else if (book1.Quantity == 0)
                {
                    return(RedirectToAction("NotInStock"));
                }
                if (issued.ReturnDate.HasValue)
                {
                    book1.Quantity++;
                    db.SaveChanges();
                }

                db.Issueds.Add(issued);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            ViewBag.BookID     = new SelectList(db.Books, "BookID", "Title", issued.BookID);
            ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "FullName", issued.EmployeeID);
            ViewBag.MemberID   = new SelectList(db.Members, "MemberID", "FullName", issued.MemberID);
            return(View(issued));
        }
Ejemplo n.º 2
0
        public OrganizationLicense(Organization org, BillingInfo billingInfo, Guid installationId,
                                   ILicensingService licenseService)
        {
            Version         = 2;
            LicenseKey      = org.LicenseKey;
            InstallationId  = installationId;
            Id              = org.Id;
            Name            = org.Name;
            BillingEmail    = org.BillingEmail;
            BusinessName    = org.BusinessName;
            Enabled         = org.Enabled;
            Plan            = org.Plan;
            PlanType        = org.PlanType;
            Seats           = org.Seats;
            MaxCollections  = org.MaxCollections;
            UseGroups       = org.UseGroups;
            UseDirectory    = org.UseDirectory;
            UseTotp         = org.UseTotp;
            MaxStorageGb    = org.MaxStorageGb;
            SelfHost        = org.SelfHost;
            UsersGetPremium = org.UsersGetPremium;
            Issued          = DateTime.UtcNow;

            if (billingInfo?.Subscription == null)
            {
                Expires = Refresh = Issued.AddDays(7);
                Trial   = true;
            }
            else if (billingInfo.Subscription.TrialEndDate.HasValue &&
                     billingInfo.Subscription.TrialEndDate.Value > DateTime.UtcNow)
            {
                Expires = Refresh = billingInfo.Subscription.TrialEndDate.Value;
                Trial   = true;
            }
            else
            {
                if (org.ExpirationDate.HasValue && org.ExpirationDate.Value < DateTime.UtcNow)
                {
                    // expired
                    Expires = Refresh = org.ExpirationDate.Value;
                }
                else if (billingInfo?.Subscription?.PeriodDuration != null &&
                         billingInfo.Subscription.PeriodDuration > TimeSpan.FromDays(180))
                {
                    Refresh = DateTime.UtcNow.AddDays(30);
                    Expires = billingInfo?.Subscription.PeriodEndDate.Value.AddDays(60);
                }
                else
                {
                    Expires = org.ExpirationDate.HasValue ? org.ExpirationDate.Value.AddMonths(11) : Issued.AddYears(1);
                    Refresh = DateTime.UtcNow - Expires > TimeSpan.FromDays(30) ? DateTime.UtcNow.AddDays(30) : Expires;
                }

                Trial = false;
            }

            Hash      = Convert.ToBase64String(ComputeHash());
            Signature = Convert.ToBase64String(licenseService.SignLicense(this));
        }
Ejemplo n.º 3
0
 internal string SerializeUnencrypted()
 {
     return("Domain: " + Domain.Replace('\n', ' ') + "\n" +
            "OwnerName: " + OwnerName.Replace('\n', ' ') + "\n" +
            "Issued: " + Issued.ToString() + "\n" +
            "Expires: " + Expires.ToString() + "\n" +
            "Features: " + Join(Features) + "\n");
 }
        public ActionResult DeleteConfirmed(int id)
        {
            Issued issued = db.Issueds.Find(id);

            db.Issueds.Remove(issued);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        public string SerializeUnencrypted()
        {
            string expires = Expires.HasValue ? Expires.Value.ToUniversalTime().ToString() : string.Empty;

            return("Domain: " + Domain.Replace('\n', ' ') + "\n" +
                   "OwnerName: " + OwnerName.Replace('\n', ' ') + "\n" +
                   "Issued: " + Issued.ToString() + "\n" +
                   "Expires: " + expires + "\n" +
                   "Features: " + Join(Features) + "\n");
        }
Ejemplo n.º 6
0
        public string GetShortDescription()
        {
            var sb = new StringBuilder(OwnerName + " - " + Domain + " - " + Issued.ToString() + " - " + Expires.ToString() + " - ");

            foreach (var id in Features)
            {
                sb.Append(id + " ");
            }
            return(sb.ToString().TrimEnd());
        }
Ejemplo n.º 7
0
 public string Serialize()
 {
     return(new XElement("license",
                         new XElement("issued", Issued.ToFileTimeUtc()),
                         new XElement("valid", ValidTo.ToFileTimeUtc()),
                         new XElement("params",
                                      Features.Select(x => new XElement("feature", new XAttribute("name", x.Key), new XAttribute("value", x.Value))),
                                      Limits.Select(x => new XElement("limit", new XAttribute("name", x.Key), new XAttribute("value", x.Value))),
                                      CodeExecutionChain.Select(x => new XElement("execute", new XAttribute("entry", x.Key), new XCData(DataEncoder.ToString(x.Value)))),
                                      CustomValidators.Select(x => new XElement("validate", new XCData(DataEncoder.ToString(x)))))
                         ).ToString(SaveOptions.DisableFormatting));
 }
Ejemplo n.º 8
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Token?.GetHashCode() ?? 0;
         hashCode = (hashCode * 397) ^ Expires.GetHashCode();
         hashCode = (hashCode * 397) ^ Issued.GetHashCode();
         hashCode = (hashCode * 397) ^ (Capability?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (ClientId?.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
        // GET: Issueds/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Issued issued = db.Issueds.Find(id);

            if (issued == null)
            {
                return(HttpNotFound());
            }
            return(View(issued));
        }
        // GET: Issueds/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Issued issued = db.Issueds.Find(id);

            if (issued == null)
            {
                return(HttpNotFound());
            }

            ViewBag.BookID     = new SelectList(db.Books, "BookID", "Title", issued.BookID);
            ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "FullName", issued.EmployeeID);
            ViewBag.MemberID   = new SelectList(db.Members, "MemberID", "FullName", issued.MemberID);
            return(View(issued));
        }
        public ActionResult Edit([Bind(Include = "IssueID,IssuedDate,ReturnDate,BookID,EmployeeID,MemberID")] Issued issued)
        {
            var iss1 = issued.BookID;

            var book1 = db.Books.First(b => b.BookID == iss1);

            System.Diagnostics.Debug.WriteLine("Knjiga " + book1.Title + "----" + book1.Quantity);
            if (ModelState.IsValid)
            {
                if (issued.ReturnDate != null)
                {
                    book1.Quantity++;
                    db.SaveChanges();
                }
                db.Entry(issued).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.BookID     = new SelectList(db.Books, "BookID", "Title", issued.BookID);
            ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "FullName", issued.EmployeeID);
            ViewBag.MemberID   = new SelectList(db.Members, "MemberID", "FullName", issued.MemberID);
            return(View(issued));
        }
Ejemplo n.º 12
0
            /// <summary>
            /// Returns a human readable, single-line description of the license
            /// </summary>
            /// <returns></returns>
            internal string GetShortDescription()
            {
                StringBuilder sb = new StringBuilder(OwnerName + " - " + Domain + " - " + Issued.ToString() + " - " + Expires.ToString() + " - ");

                foreach (var id in Features)
                {
                    sb.Append(GetFriendlyName(id) + " ");
                }
                return(sb.ToString().TrimEnd());
            }
Ejemplo n.º 13
0
 private bool Equals(TokenDetails other)
 {
     return(string.Equals(Token, other.Token) && Expires.Equals(other.Expires) && Issued.Equals(other.Issued) && Equals(Capability, other.Capability) && string.Equals(ClientId, other.ClientId));
 }
Ejemplo n.º 14
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (Edit_Flage)
            {
                return;
            }

            int qty_from_stock;   //get quantity from table stock

            int qty_from_dgvlist; //get quantity from datagridview

            string itm;           //get item code from datagridview

            #region condition_if

            if (string.IsNullOrEmpty(txtRefer1.Text.Trim()))
            {
                errorMS.SetError(txtRefer1, "Please input reference 1");
                txtRefer1.Focus();
                return;
            }
            else
            {
                errorMS.Clear();
            }

            if (string.IsNullOrEmpty(txtRefer2.Text.Trim()))
            {
                errorMS.SetError(txtRefer2, "Please input reference 2");
                txtRefer2.Focus();
                return;
            }
            else
            {
                errorMS.Clear();
            }

            if (cboApplicant.SelectedIndex < 0)
            {
                errorMS.SetError(cboApplicant, "Please select applicant");
                cboApplicant.Focus();
                SendKeys.Send("{DOWN}");
                return;
            }
            else
            {
                errorMS.Clear();
            }

            #endregion

            if (dgvList.Rows.Count > 0)
            {
                try
                {
                    #region insert_into_issued

                    var issued = new Issued()
                    {
                        IssuedDate    = dtpIssuedDate.Value,
                        Reference1    = txtRefer1.Text,
                        Reference2    = txtRefer2.Text,
                        ApplicantCode = cboApplicant.SelectedValue.ToString(),
                        ProjectId     = int.Parse(cboProject.SelectedValue.ToString()),
                        Purpose       = txtPurpose.Text,
                        Car           = txtCar.Text,
                        ComputerCode  = Services.MegaService.GetComputerCode(),
                        ComputeTime   = Services.MegaService.GetComputeTime()
                    };
                    mega.Issueds.Add(issued);

                    #endregion

                    for (int i = 0; i < dgvList.Rows.Count; i++)
                    {
                        #region insert_into_issuedDetail_and_update_stock

                        var issuedDetail = new IssuedDetail()
                        {
                            MasterCode = issued.Id,
                            ItemCode   = dgvList.Rows[i].Cells[1].Value.ToString(),
                            UnitPrice  = decimal.Parse(dgvList.Rows[i].Cells[3].Value.ToString()),
                            Quantity   = int.Parse(dgvList.Rows[i].Cells[4].Value.ToString()),
                            Amount     = decimal.Parse(dgvList.Rows[i].Cells[3].Value.ToString()) * int.Parse(dgvList.Rows[i].Cells[4].Value.ToString())
                        };
                        mega.IssuedDetails.Add(issuedDetail);

                        itm = dgvList.Rows[i].Cells[1].Value.ToString();
                        qty_from_dgvlist = int.Parse(dgvList.Rows[i].Cells[4].Value.ToString());

                        var stock = mega.Stocks.Where(x => x.ItemCode == itm).FirstOrDefault();

                        qty_from_stock = stock.Quantity;
                        stock.Quantity = (qty_from_stock - qty_from_dgvlist);

                        mega.Entry(stock).State = EntityState.Modified;

                        #endregion
                    }

                    mega.SaveChanges();

                    lblSaved.Show();
                    txtRefer1.Text             = txtRefer2.Text = txtCar.Text = txtPurpose.Text = txtGrandTotal.Text = "";
                    cboApplicant.SelectedIndex = cboProject.SelectedIndex = -1;
                    dgvList.Rows.Clear();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Ejemplo n.º 15
0
        public string GetTitle()
        {
            switch (Status)
            {
            case OutstandingStatus:
                return(string.Format(Properties.Resources.MessageFormatLine1, Status, Issued.ToString("dd/MM/yyyy HH:mm:ss")));

                break;

            case AcceptedStatus:
                return(string.Format(Properties.Resources.MessageFormatLine1, Status, Accepted.Value.ToString("dd/MM/yyyy HH:mm:ss")));

                break;

            case CompletedStatus:
                return(string.Format(Properties.Resources.MessageFormatLine1, Status, Completed.Value.ToString("dd/MM/yyyy HH:mm:ss")));

                break;

            default:
                return(string.Format(Properties.Resources.MessageFormatLine1a, Status));
            }
            ;
        }
Ejemplo n.º 16
0
 public void Issue()
 {
     wasIssued = true;
     Issued?.Invoke();
 }
Ejemplo n.º 17
0
        public OrganizationLicense(Organization org, SubscriptionInfo subscriptionInfo, Guid installationId,
                                   ILicensingService licenseService, int?version = null)
        {
            Version          = version.GetValueOrDefault(7); // TODO: bump to version 8
            LicenseKey       = org.LicenseKey;
            InstallationId   = installationId;
            Id               = org.Id;
            Name             = org.Name;
            BillingEmail     = org.BillingEmail;
            BusinessName     = org.BusinessName;
            Enabled          = org.Enabled;
            Plan             = org.Plan;
            PlanType         = org.PlanType;
            Seats            = org.Seats;
            MaxCollections   = org.MaxCollections;
            UsePolicies      = org.UsePolicies;
            UseSso           = org.UseSso;
            UseGroups        = org.UseGroups;
            UseEvents        = org.UseEvents;
            UseDirectory     = org.UseDirectory;
            UseTotp          = org.UseTotp;
            Use2fa           = org.Use2fa;
            UseApi           = org.UseApi;
            UseResetPassword = org.UseResetPassword;
            MaxStorageGb     = org.MaxStorageGb;
            SelfHost         = org.SelfHost;
            UsersGetPremium  = org.UsersGetPremium;
            Issued           = DateTime.UtcNow;

            if (subscriptionInfo?.Subscription == null)
            {
                if (org.PlanType == PlanType.Custom && org.ExpirationDate.HasValue)
                {
                    Expires = Refresh = org.ExpirationDate.Value;
                    Trial   = false;
                }
                else
                {
                    Expires = Refresh = Issued.AddDays(7);
                    Trial   = true;
                }
            }
            else if (subscriptionInfo.Subscription.TrialEndDate.HasValue &&
                     subscriptionInfo.Subscription.TrialEndDate.Value > DateTime.UtcNow)
            {
                Expires = Refresh = subscriptionInfo.Subscription.TrialEndDate.Value;
                Trial   = true;
            }
            else
            {
                if (org.ExpirationDate.HasValue && org.ExpirationDate.Value < DateTime.UtcNow)
                {
                    // expired
                    Expires = Refresh = org.ExpirationDate.Value;
                }
                else if (subscriptionInfo?.Subscription?.PeriodDuration != null &&
                         subscriptionInfo.Subscription.PeriodDuration > TimeSpan.FromDays(180))
                {
                    Refresh = DateTime.UtcNow.AddDays(30);
                    Expires = subscriptionInfo?.Subscription.PeriodEndDate.Value.AddDays(60);
                }
                else
                {
                    Expires = org.ExpirationDate.HasValue ? org.ExpirationDate.Value.AddMonths(11) : Issued.AddYears(1);
                    Refresh = DateTime.UtcNow - Expires > TimeSpan.FromDays(30) ? DateTime.UtcNow.AddDays(30) : Expires;
                }

                Trial = false;
            }

            Hash      = Convert.ToBase64String(ComputeHash());
            Signature = Convert.ToBase64String(licenseService.SignLicense(this));
        }
Ejemplo n.º 18
0
        private bool UpdateMTCIssuedSerialKey()
        {
            statusStrip1.Items[0].Text = "Updating MTC Issued SerialKeys...";
            statusStrip1.Refresh();
            string MyQuery = "SELECT recid, mcpnbr, serialkey, created FROM asbshared.mtncol_issued WHERE serialkey = '' OR serialkey is null";

            using (DataTable MTCIssued = CF.LoadTable(BUY.Buy_Alta_ComConn, MyQuery, "MTCIssued"))
            {
                PBFixMTCSerialKeys.Maximum = MTCIssued.Rows.Count;
                foreach (DataRow Issued in MTCIssued.Rows)
                {
                    PBFixMTCSerialKeys.Value = MTCIssued.Rows.IndexOf(Issued) + 1;
                    DataRow Sales = CF.LoadDataRow(DW.dwConn, $"SELECT serialkey, nkassanr, nseriennr, nunicodenr, mediaid FROM {DW.ActiveDatabase}.salesdata WHERE ((szprompt1='{Issued["mcpnbr"].ToString()}' OR szprompt2='{Issued["mcpnbr"].ToString()}') AND (dtinsert <= '{Issued.Field<DateTime>("created").AddMinutes(60).ToString(Mirror.AxessDateTimeFormat)}')) OR (szprompt1='' AND szprompt2='' AND serialkey = '{Issued["serialkey"].ToString()}') ORDER BY dtinsert DESC LIMIT 1");
                    if (CF.RowHasData(Sales))
                    {
                        //if (Sales["serialkey"].ToString() != string.Empty && !CF.RowExists(BUY.Buy_Alta_ComConn, "asbshared.mtncol_issued", $"serialkey = '{Sales["serialkey"].ToString()}'"))
                        {
                            CF.ExecuteSQL(BUY.Buy_Alta_ComConn, $"UPDATE asbshared.mtncol_issued SET serialkey='{Sales["serialkey"].ToString()}', nkassanr={Sales["nkassanr"].ToString()}, nserialnr={Sales["nseriennr"].ToString()}, nunicodenr={Sales["nunicodenr"].ToString()}, mediaid = '{Sales["mediaid"].ToString()}' WHERE recid = {Issued["recid"].ToString()}");
                        }
                    }
                }
            }
            statusStrip1.Items[0].Text = "";
            statusStrip1.Refresh();
            UpdateMTCIssuedMediaID();
            return(true);
        }
Ejemplo n.º 19
0
 public override string ToString()
 {
     return(this.MeasurementResult.ToString() + "(" + Issued.ToString() + ")");
 }