Пример #1
0
    protected void Btnsave_Click(object sender, EventArgs e)
    {
        db = new LinqToSqlDataContext();
        string optName = "";
        //update options
        Audit audit = new Audit();

        if (Session[enumSessions.Option_Id.ToString()] != null)
        {
            int id = Convert.ToInt32(Session[enumSessions.Option_Id.ToString()].ToString());
            //update
            Option opp = (from x in db.Options
                          where x.OptID == id
                          select x).First();
            opp.OptionName = txtoptName.Text;
            optName        = txtoptName.Text;
            opp.OptionDesc = txtdesc.Text;

            string script = "alertify.alert('" + ltrOptionUpdated.Text + "');";
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
            audit.Notes = "OptId: " + id + ", OptName: " + opp.OptionName + ", Description: " + opp.OptionDesc;
        }
        //create new option
        else
        {
            Option opt = new Option
            {
                OptionName = txtoptName.Text.ToString(),
                OptionDesc = txtdesc.Text.ToString()
            };

            optName = txtoptName.Text;
            db.Options.InsertOnSubmit(opt);
            string script = "alertify.alert('" + ltrOptionCreated.Text + "');";
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
            audit.Notes = "OptId: " + opt.OptID + ", OptName: " + opt.OptionName + ", Description: " + opt.OptionDesc;
        }
        pnlOptionDetails.Visible = false;
        pnlOptionList.Visible    = true;
        db.SubmitChanges();
        LoadData();

        audit.UserName  = Session[enumSessions.User_Name.ToString()].ToString();
        audit.ChangeID  = Convert.ToInt32(enumAudit.Manage_Options);
        audit.CreatedOn = DateTime.Now;
        if (Request.ServerVariables["LOGON_USER"] != null)
        {
            audit.WindowsUser = Request.ServerVariables["LOGON_USER"];
        }
        audit.IPAddress = Request.UserHostAddress;
        db.Audits.InsertOnSubmit(audit);
        db.SubmitChanges();
    }
Пример #2
0
        /// <summary>
        /// Odebere danou jednotku.
        /// </summary>
        /// <param name="unitName">Jméno jednotky k odebrání. </param>
        public static void RemoveUnit(string unitName)
        {
            LinqToSqlDataContext db = DatabaseSetup.Database;
            Unit unitToDelete       = (from goner in db.Units
                                       where goner.name == unitName
                                       select goner).Single();

            // Zkontrolovat, jestli nějaký produkt tuto jednotku nepoužívá
            int unitGonerId = unitToDelete.id;
            IEnumerable <int?> productUnitIds = from p in db.Products
                                                select p.unit;

            foreach (int?singleId in productUnitIds)
            {
                if (singleId == unitGonerId)
                {
                    throw new UnitInUseException();
                }
            }



            db.Units.DeleteOnSubmit(unitToDelete);
            db.SubmitChanges();
        }
Пример #3
0
        /// <summary>
        /// Pokusí se přidat novou jednotku. V případě neúspěchu vrací false.
        /// </summary>
        /// <param name="name">Jméno nové jednotky</param>
        ///
        public static void AddUnit(string name)
        {
            LinqToSqlDataContext db = DatabaseSetup.Database;

            // Kontrola unikátnosti jména
            IEnumerable <string> allNames = StorageSetup.GetUnitNames();

            foreach (string n in allNames)
            {
                if (n == name)
                {
                    throw new ExistingUnitNameException();
                }
            }

            Unit u = new Unit();

            u.name = name;
            db.Units.InsertOnSubmit(u);

            try
            {
                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                Errors.SaveError(ex.Message);
                throw new UnitAddExcepton();
            }
        }
Пример #4
0
        /// <summary>
        /// Přidá nový produkt do databáze
        /// </summary>
        /// <param name="product">Produkt pro přidání.</param>
        public static void AddProduct(Product product)
        {
            LinqToSqlDataContext db = DatabaseSetup.Database;

            db.Products.InsertOnSubmit(product);
            db.SubmitChanges();
        }
Пример #5
0
        public static void DeleteProduct(int productId)
        {
            LinqToSqlDataContext db = DatabaseSetup.Database;
            Product selectedProduct = (from p in db.Products
                                       where p.id == productId
                                       select p).Single();
            //Smazání obrazků
            //Nejdříve najdeme propojovací záznamy pro daný produkt

            IEnumerable <ProductImage> joinTable = from j in db.ProductImages
                                                   where j.idProduct == productId
                                                   select j;
            // Výsledek spojíme s uloženými obrázky, výsledkem je kolekce obrázků ke smazání
            IEnumerable <ImagesTable> imagesToDelete = from j in joinTable
                                                       join img in db.ImagesTables
                                                       on j.idImage equals img.id
                                                       select img;

            // Smazání
            db.ImagesTables.DeleteAllOnSubmit(imagesToDelete);
            db.Products.DeleteOnSubmit(selectedProduct);

            try
            {
                db.SubmitChanges();
            }
            catch
            {
                throw new NotImplementedException();
            }
        }
Пример #6
0
        public int IssueCollectionTasks()
        {
            int tasksIssued = 0;

            //Query Collection Tasks
            LinqToSqlDataContext context = new LinqToSqlDataContext();
            IQueryable <HaystackLibrary.CollectionTask> results =
                from r in context.CollectionTasks
                where r.State == CollectionsTaskState.Approved.ToString()
                select r;

            //Write Queue Message, Update State to "Issued"
            foreach (HaystackLibrary.CollectionTask r in results)
            {
                r.State  = CollectionsTaskState.Issued.ToString();
                r.Issued = DateTime.UtcNow;

                string message = CollectionsTaskHelper.DatabaseTaskToMessage(r);

                StorageClientHelper.AddQueueMessage(QueueType.Collections, SourceType.Twitter, message);
                tasksIssued++;

                string task = string.Format("{0} {1} {2} {3} {4} {5} {6} ",
                                            r.Id.ToString(), r.State, r.Created.ToString(), r.Project, r.Source, r.Command, r.Target);

                Console.WriteLine(task);
            }

            //Submit Changes
            context.SubmitChanges();

            return(tasksIssued);
        }
Пример #7
0
        public static Boolean UpdateProductGrade(ProductCode_Grade_Map productGrade)
        {
            LinqToSqlDataContext db = null;

            try
            {
                db = new LinqToSqlDataContext();
                ProductCode_Grade_Map objGrade = db.ProductCode_Grade_Maps.Single(i => i.ProductGradeID == productGrade.ProductGradeID);
                objGrade.ProductCode = productGrade.ProductCode;
                objGrade.Grade       = productGrade.Grade;
                objGrade.CreatedOn   = productGrade.CreatedOn;
                objGrade.CreatedBy   = productGrade.CreatedBy;
                objGrade.IsDeleted   = productGrade.IsDeleted;
                db.SubmitChanges();


                db.Dispose();

                return(true);
            }
            catch (Exception objException)
            {
                db = new CSLOrderingARCBAL.LinqToSqlDataContext();
                db.USP_SaveErrorDetails("ProductBAL", "UpdateProductGrade", Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "", null, false, null);
                return(false);
            }
        }
Пример #8
0
        public static Boolean InsertProductGrade(ProductCode_Grade_Map productGrade)
        {
            LinqToSqlDataContext db = new LinqToSqlDataContext();

            int count = (from gp in db.ProductCode_Grade_Maps
                         where gp.ProductCode == productGrade.ProductCode
                         select gp
                         ).Count();



            if (count > 0)
            {
                return(false);
            }
            else
            {
                ProductCode_Grade_Map objProductGrade = new ProductCode_Grade_Map();

                objProductGrade.ProductCode = productGrade.ProductCode;
                objProductGrade.Grade       = productGrade.Grade;
                objProductGrade.CreatedOn   = productGrade.CreatedOn;
                objProductGrade.CreatedBy   = productGrade.CreatedBy;
                objProductGrade.IsDeleted   = productGrade.IsDeleted;
                db.ProductCode_Grade_Maps.InsertOnSubmit(objProductGrade); // insert
                db.SubmitChanges();

                return(true);
            }
        }
Пример #9
0
        private void btnDelAllUsers_Click(object sender, RoutedEventArgs e)
        {
            LinqToSqlDataContext db       = PASS.GeneralClasses.DatabaseSetup.Database;
            IEnumerable <User>   allUsers = from u in db.Users
                                            select u;


            foreach (User u in allUsers)
            {
                if (u.id != PASS.GeneralClasses.Authentification.AuthUser.Id) // Aktuální uživatel nepůjde smazat
                {
                    db.Users.DeleteOnSubmit(u);
                }
            }

            try
            {
                db.SubmitChanges();
                ManagementSetup.InitializeUserTable(dgUsers);
                DialogHelper.ShowInfo("Všichni uživatelé kromě aktuálně přihlášeného byli odstraněni.");
            }
            catch
            {
                throw new NotImplementedException();
            }
        }
Пример #10
0
        /// <summary>
        /// Vytvoří nového uživatele. Při úspěchu vrací true.
        /// </summary>
        /// <param name="username">Unikátní uživatelské jméno</param>
        /// <param name="pswd">Heslo</param>
        /// <param name="role">Existující role</param>
        /// <returns></returns>
        public static bool NewUser(string username, string pswd, string role)
        {
            if (username == "" || pswd == "")
            {
                return(false);
            }

            LinqToSqlDataContext db = DatabaseSetup.Database;

            PASS.User newUser = new PASS.User();
            string    hashedPassword;
            string    salt;

            HashPassword(pswd, out salt, out hashedPassword);

            newUser.salt     = salt;
            newUser.pswd     = hashedPassword;
            newUser.username = username;
            newUser.userRole = (from r in db.UserRoles where (r.name.Trim() == role) select r.id).Single();
            db.Users.InsertOnSubmit(newUser);

            try
            {
                db.SubmitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                Errors.SaveError(ex.Message);
                DatabaseSetup.UndoChanges();
                return(false);
            }
        }
Пример #11
0
        /// <summary>
        /// Změní heslo uživatele. V případě úspěchu vrací true.
        /// </summary>
        /// <param name="user">Uživatel</param>
        /// <param name="password">Nové heslo</param>
        /// <returns></returns>
        public static void ChangePassword(int userId, string password)
        {
            if (password == "" || userId < 0)
            {
                throw new NotImplementedException();
            }

            LinqToSqlDataContext db = DatabaseSetup.Database;
            User selectedUser       = (from u in db.Users
                                       where u.id == userId
                                       select u).Single();


            string hashedPassword;
            string salt;

            HashPassword(password, out salt, out hashedPassword);

            try
            {
                selectedUser.pswd = hashedPassword;
                selectedUser.salt = salt;
                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                Errors.SaveError(ex.Message);
                DatabaseSetup.UndoChanges();
                throw new NotImplementedException();
            }
        }
Пример #12
0
        /// <summary>
        /// Změní uživatelskou roli.
        /// </summary>
        /// <param name="userId">ID uživatele</param>
        /// <param name="userRole">Nová uživatelská role</param>
        /// <returns></returns>
        public static void ChangeUserRole(int userId, string userRole)
        {
            if (userRole == "" || userId < 0)
            {
                throw new NotImplementedException();
            }

            LinqToSqlDataContext db = DatabaseSetup.Database;

            User selectedUser = (from u in db.Users
                                 where u.id == userId
                                 select u).Single();

            UserRole r = (from role in db.UserRoles
                          where role.name == userRole
                          select role).Single();

            selectedUser.userRole = r.id;

            try
            {
                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                Errors.SaveError(ex.Message);
                DatabaseSetup.UndoChanges();
                throw new NotImplementedException();
            }
        }
 protected void gvBillingCodes_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     try
     {
         Label lblId      = (Label)gvBillingCodes.Rows[e.RowIndex].FindControl("lblID");
         int   idToDelete = Convert.ToInt32(lblId.Text);
         db = new LinqToSqlDataContext();
         var overrideCodeToDelete = db.OverideBillingCodes.Single(a => a.id == idToDelete);
         if (overrideCodeToDelete != null)
         {
             db.OverideBillingCodes.DeleteOnSubmit(overrideCodeToDelete);
             db.SubmitChanges();
             string script = "alertify.alert('" + ltrDeleteSuccess.Text + "');";
             ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
         }
         else
         {
             string script = "alertify.alert('" + ltrDeleteFail.Text + "');";
             ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
         }
         BindGrid();
     }
     catch (Exception objException)
     {
         string script = "alertify.alert('" + objException.Message + "');";
         ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
         db = new CSLOrderingARCBAL.LinqToSqlDataContext();
         db.USP_SaveErrorDetails(Request.Url.ToString(), "gvBillingCodes_RowDeleting", Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "", HttpContext.Current.Request.UserHostAddress, false, Convert.ToString(HttpContext.Current.Session[enumSessions.User_Id.ToString()]));
     }
 }
Пример #14
0
        /// <summary>
        /// Vytvoří nový produkt a přidá ho do databáze.
        /// </summary>
        /// <param name="name">Jméno produktu. Nemusí být unikátní.</param>
        /// <param name="quantity">Množství (počet kusů)</param>
        /// <param name="unitId">ID jednotky</param>
        /// <param name="unitQuantity">Množství zvolené jednotky</param>
        /// <param name="expirationDate">Datum expirace</param>
        /// <param name="code">Kód zboží</param>
        /// <param name="price">Cena za kus, popřípadě za jednoku množství</param>
        /// <param name="priceForUnit">Cena se účtuje za jednotku množství, ne za počet kusů.</param>
        /// <returns></returns>
        public static bool AddProduct(string name, int quantity, int unitId, decimal unitQuantity, DateTime?expirationDate, int code, decimal price, bool priceForUnit, char VAT)
        {
            LinqToSqlDataContext db = DatabaseSetup.Database;
            Product product         = new Product()
            {
                name           = name,
                quantity       = quantity,
                unit           = unitId,
                unitQuantity   = unitQuantity,
                expirationDate = expirationDate,
                code           = code,
                price          = price,
                priceForUnit   = priceForUnit,
                vatId          = VAT
            };

            db.Products.InsertOnSubmit(product);

            try
            {
                db.SubmitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                Errors.SaveError(ex.Message);
                return(false);
            }
        }
Пример #15
0
 protected void Select_Click(object sender, EventArgs e)
 {
     try
     {
         if (ddlInstallers.SelectedIndex > -1)
         {
             Session[enumSessions.SelectedInstaller.ToString()]  = ddlInstallers.SelectedItem.Text;
             Session[enumSessions.InstallerCompanyID.ToString()] = ddlInstallers.SelectedValue.ToString();
             LinqToSqlDataContext dataCtxt = new LinqToSqlDataContext();
             if (Session[enumSessions.BulkUploadMultipleOrderId.ToString()] != null)
             {
                 int addressId = 0;
                 dataCtxt.USP_SaveInstallerDetailsInOrder(Session[enumSessions.InstallerCompanyID.ToString()].ToString(), Convert.ToInt32(Session[enumSessions.BulkUploadMultipleOrderId.ToString()]));
                 var insContactName = (from insAdd in dataCtxt.InstallerAddresses
                                       join ins in dataCtxt.Installers on insAdd.AddressID equals ins.AddressID
                                       where ins.InstallerCompanyID == new Guid(Session[enumSessions.InstallerCompanyID.ToString()].ToString())
                                       select insAdd.ContactName).Single();
                 if (insContactName != null)
                 {
                     addressId = InstallerBAL.SaveInstallerAddress(Session[enumSessions.InstallerCompanyID.ToString()].ToString(), insContactName, "", 0, "", "", "", "", "", "", Session[enumSessions.User_Name.ToString()].ToString());
                 }
                 var orderDetail = dataCtxt.Orders.Single(x => x.OrderId == Convert.ToInt32(Session[enumSessions.BulkUploadMultipleOrderId.ToString()]));
                 if (orderDetail.DeliveryAddressId == 0)
                 {
                     orderDetail.DeliveryAddressId = addressId;
                 }
                 orderDetail.ModifiedBy = Session[enumSessions.User_Name.ToString()].ToString();
                 orderDetail.ModifiedOn = DateTime.Now;
                 dataCtxt.SubmitChanges();
                 getBulkuploadOrderItems(e);
                 // Session[enumSessions.BulkUploadMultipleOrderId.ToString()] = null;
                 AjaxControlToolkit.ModalPopupExtender mpInstaller = Parent.FindControl("mpInstaller") as AjaxControlToolkit.ModalPopupExtender;
                 mpInstaller.Hide();
             }
             else
             {
                 dataCtxt.USP_SaveInstallerDetailsInOrder(Session[enumSessions.InstallerCompanyID.ToString()].ToString(), Convert.ToInt32(Session[enumSessions.OrderId.ToString()]));
                 dataCtxt.Dispose();
                 Response.Redirect("Checkout.aspx");
             }
         }
         else
         {
             string script = "alertify.alert('" + ltrSelect.Text + "');";
             ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
         }
     }
     catch (System.Threading.ThreadAbortException ex)
     {
         //
     }
     catch (Exception objException)
     {
         CSLOrderingARCBAL.LinqToSqlDataContext db;
         db = new CSLOrderingARCBAL.LinqToSqlDataContext();
         db.USP_SaveErrorDetails(Request.Url.ToString(), ((System.Reflection.MemberInfo)(objException.TargetSite)).Name, Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "", HttpContext.Current.Request.UserHostAddress, false, Convert.ToString(HttpContext.Current.Session[enumSessions.User_Id.ToString()]));
     }
 }
Пример #16
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string productCode = "";

        if (!String.IsNullOrEmpty(txtProductCode.Text.Trim()))
        {
            ProductCode_Grade_Map objGrade = new ProductCode_Grade_Map();

            objGrade.ProductCode = txtProductCode.Text.Trim();
            productCode          = txtProductCode.Text.Trim();
            objGrade.Grade       = ddlGrade.SelectedValue.ToString();
            objGrade.CreatedOn   = DateTime.Now;
            objGrade.CreatedBy   = Session[enumSessions.User_Name.ToString()].ToString();
            objGrade.IsDeleted   = false;
            Boolean flag = false;
            if (ViewState["ProductGradeID"] != null)
            {
                objGrade.ProductGradeID = Convert.ToInt32(ViewState["ProductGradeID"]);
                flag = ProductBAL.UpdateProductGrade(objGrade);
            }
            else
            {
                flag = ProductBAL.InsertProductGrade(objGrade);
            }
            if (flag == false)
            {
                string script = "alertify.alert('" + ltrDuplicate.Text + "');";
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
            }
            else
            {
                string script = "alertify.alert('" + ltrSaved.Text + "');";
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
            }

            LoadData();
            ClearControl();
            ViewState["ProductGradeID"] = null;
        }
        pnlGradeDetails.Visible = false;
        pnlGradeList.Visible    = true;

        LinqToSqlDataContext db = new LinqToSqlDataContext();
        Audit audit             = new Audit();

        audit.UserName  = Session[enumSessions.User_Name.ToString()].ToString();
        audit.ChangeID  = Convert.ToInt32(enumAudit.Manage_Products_Grade);
        audit.CreatedOn = DateTime.Now;
        audit.Notes     = "Grade: " + ddlGrade.SelectedValue.ToString() + ", Product Code: " + productCode;
        if (Request.ServerVariables["LOGON_USER"] != null)
        {
            audit.WindowsUser = Request.ServerVariables["LOGON_USER"];
        }
        audit.IPAddress = Request.UserHostAddress;
        db.Audits.InsertOnSubmit(audit);
        db.SubmitChanges();
    }
Пример #17
0
 public void RemoveEvent(int id)
 {
     using (LinqToSqlDataContext dataContext = new LinqToSqlDataContext())
     {
         LibraryEvents removedEvent = dataContext.LibraryEvents.FirstOrDefault(ev => ev.ID == id);
         dataContext.LibraryEvents.DeleteOnSubmit(removedEvent);
         dataContext.SubmitChanges();
     }
 }
Пример #18
0
 public void UpdateUser(int id, string name)
 {
     using (LinqToSqlDataContext dataContext = new LinqToSqlDataContext())
     {
         Users updatedUser = dataContext.Users.FirstOrDefault(user => user.ID == id);
         updatedUser.Name = name;
         dataContext.SubmitChanges();
     }
 }
    protected void gvARCIns_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            LinkButton lkedit = gvARCIns.Rows[e.RowIndex].FindControl("lnkEdit") as LinkButton;
            int        Id     = Convert.ToInt16(lkedit.CommandArgument);
            db = new LinqToSqlDataContext();
            var rowtoDelete = (from data in db.ARC_AccessCodes.Where(d => d.ID == Id)
                               select data).SingleOrDefault();
            if (rowtoDelete != null)
            {
                db.ARC_AccessCodes.DeleteOnSubmit(rowtoDelete);
                db.SubmitChanges();
                string script = "alertify.alert('" + ltrDeleteSuccess.Text + "');";
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
            }
            else
            {
                string script = "alertify.alert('" + ltrDeleteFail.Text + "');";
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
            }
            BindGrid();

            Audit audit = new Audit();
            audit.UserName  = Session[enumSessions.User_Name.ToString()].ToString();
            audit.ChangeID  = Convert.ToInt32(enumAudit.Manage_ARC_AccessCode);
            audit.CreatedOn = DateTime.Now;
            audit.Notes     = "Delete - " + rowtoDelete;
            if (Request.ServerVariables["LOGON_USER"] != null)
            {
                audit.WindowsUser = Request.ServerVariables["LOGON_USER"];
            }
            audit.IPAddress = Request.UserHostAddress;
            db.Audits.InsertOnSubmit(audit);
            db.SubmitChanges();
        }
        catch (Exception objException)
        {
            string script = "alertify.alert('" + objException.Message + "');";
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
            db = new CSLOrderingARCBAL.LinqToSqlDataContext();
            db.USP_SaveErrorDetails(Request.Url.ToString(), "gvARCIns_RowDeleting", Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "", HttpContext.Current.Request.UserHostAddress, false, Convert.ToString(HttpContext.Current.Session[enumSessions.User_Id.ToString()]));
        }
    }
Пример #20
0
    protected void LinkButtondelete_click(object sender, System.EventArgs e)
    {
        db = new LinqToSqlDataContext();
        try
        {
            Audit       audit = new Audit();
            LinkButton  lbopt = sender as LinkButton;
            GridViewRow gvr   = (GridViewRow)lbopt.NamingContainer;
            Label       lbl2  = gvr.Cells[1].FindControl("OptID") as Label;
            Session[enumSessions.Option_Id.ToString()] = lbl2.Text;
            //     delete mappings

            int id   = Convert.ToInt32(Session[enumSessions.Option_Id.ToString()].ToString());
            var opts = db.Product_Option_Maps.Where(op => op.OptionId == id);
            db.Product_Option_Maps.DeleteAllOnSubmit(opts);


            //delete master
            Option opt = db.Options.Where(op => op.OptID == id).Single();
            db.Options.DeleteOnSubmit(opt);

            db.SubmitChanges();
            LoadData();
            string script = "alertify.alert('" + ltrOptionDeleted.Text + "');";
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
            audit.Notes     = "Delete - Id: " + opts;
            audit.UserName  = Session[enumSessions.User_Name.ToString()].ToString();
            audit.ChangeID  = Convert.ToInt32(enumAudit.Manage_Options);
            audit.CreatedOn = DateTime.Now;
            if (Request.ServerVariables["LOGON_USER"] != null)
            {
                audit.WindowsUser = Request.ServerVariables["LOGON_USER"];
            }
            audit.IPAddress = Request.UserHostAddress;
            db.Audits.InsertOnSubmit(audit);
            db.SubmitChanges();
        }
        catch (Exception objException)
        {
            db = new CSLOrderingARCBAL.LinqToSqlDataContext();
            db.USP_SaveErrorDetails(Request.Url.ToString(), "LinkButtondelete_click", Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "", HttpContext.Current.Request.UserHostAddress, false, Convert.ToString(HttpContext.Current.Session[enumSessions.User_Id.ToString()]));
        }
    }
Пример #21
0
 public void UpdateCatalog(int id, string title, string author)
 {
     using (LinqToSqlDataContext dataContext = new LinqToSqlDataContext())
     {
         Catalogs updatedCatalog = dataContext.Catalogs.FirstOrDefault(catalog => catalog.ID == id);
         updatedCatalog.Title  = title;
         updatedCatalog.Author = author;
         dataContext.SubmitChanges();
     }
 }
Пример #22
0
 public void UpdateState(int id, int catalogId, bool isBorrowed)
 {
     using (LinqToSqlDataContext dataContext = new LinqToSqlDataContext())
     {
         States updatedState = dataContext.States.FirstOrDefault(state => state.ID == id);
         updatedState.CatalogId  = catalogId;
         updatedState.IsBorrowed = isBorrowed;
         dataContext.SubmitChanges();
     }
 }
Пример #23
0
        public static void RemoveImage(int imageId)
        {
            LinqToSqlDataContext db       = DatabaseSetup.Database;
            ImagesTable          imgGoner = (from goner in db.ImagesTables
                                             where goner.id == imageId
                                             select goner).Single();

            db.ImagesTables.DeleteOnSubmit(imgGoner);
            db.SubmitChanges();
        }
Пример #24
0
        public static void UpdateBillInfo(string billText)
        {
            LinqToSqlDataContext db = DatabaseSetup.Database;
            Bill bill = (from b in db.Bills
                         select b).First();

            bill.billText = billText;

            db.SubmitChanges();
        }
Пример #25
0
        public static void InsertBillInfo(string billText)
        {
            LinqToSqlDataContext db = DatabaseSetup.Database;
            Bill bill = new Bill();

            bill.id       = 1; //Zatím podpora pouze jedné společnosti
            bill.billText = billText;
            db.Bills.InsertOnSubmit(bill);
            db.SubmitChanges();
        }
Пример #26
0
        public static Product CreateProduct(Product product)
        {
            using (LinqToSqlDataContext db = new LinqToSqlDataContext())
            {
                db.Products.InsertOnSubmit(product);
                db.SubmitChanges();
            }

            return(product);
        }
Пример #27
0
        public static void AddVAT(char id, int rate)
        {
            LinqToSqlDataContext db = DatabaseSetup.Database;
            Vat vat = new Vat();

            vat.id   = id;
            vat.rate = rate;
            db.Vats.InsertOnSubmit(vat);
            db.SubmitChanges();
        }
Пример #28
0
        public static void AssignImageToProduct(int productId, int imageId)
        {
            LinqToSqlDataContext db          = DatabaseSetup.Database;
            ProductImage         assignTable = new ProductImage();

            assignTable.idImage   = imageId;
            assignTable.idProduct = productId;

            db.ProductImages.InsertOnSubmit(assignTable);
            db.SubmitChanges();
        }
Пример #29
0
        public static void AddImage(ImageStruct imageStruct)
        {
            LinqToSqlDataContext db  = DatabaseSetup.Database;
            ImagesTable          img = new ImagesTable();

            byte[] array = ImageToByte(imageStruct.image);
            img.name = imageStruct.imgName;
            img.img  = array;
            db.ImagesTables.InsertOnSubmit(img);
            db.SubmitChanges();
        }
Пример #30
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            using (LinqToSqlDataContext db = new LinqToSqlDataContext())
            {
                EM_ProductParam productParameters = new EM_ProductParam();
                if (!chkAsNew.Checked)
                {
                    int paramID = 0;
                    int.TryParse(gvEMParams.SelectedValue.ToString(), out paramID);
                    productParameters = db.EM_ProductParams.Where(x => x.EM_ProductParamID == paramID).FirstOrDefault();

                    if (productParameters == null)
                    {
                        lblErrorMsg.Text = "Record not found to update.";
                        return;
                    }
                }

                productParameters.EM_ProductBillingDesc       = txtBillingDesc.Text;
                productParameters.EM_ProductBillingCommitment = Convert.ToInt32(txtBillingCommit.Text);

                productParameters.EM_CoreService             = Convert.ToInt32(txtCoreService.Text);
                productParameters.EM_CoreType                = Convert.ToInt32(txtCoreType.Text);
                productParameters.EM_InstType_Equivalent     = txtInstTypeEquiv.Text;
                productParameters.EM_CorePrimaryCluster      = Convert.ToInt32(txtPriCluster.Text);
                productParameters.EM_CorePrimarySubCluster   = Convert.ToInt32(txtPriSubcluster.Text);
                productParameters.EM_CoreSecondaryCluster    = Convert.ToInt32(txtSecondarycluster.Text);
                productParameters.EM_CoreSecondarySubCluster = Convert.ToInt32(txtSecondarySubCluster.Text);
                productParameters.EM_InstType_Type           = Convert.ToInt32(txtTypeID.Text);
                string username = SiteUtility.GetUserName();
                productParameters.EM_ModifiedBy   = username;
                productParameters.EM_ModifiedOn   = DateTime.Now;
                productParameters.Is_Deleted_Flag = chkDeleteFlag.Checked;

                if (chkAsNew.Checked)
                {
                    productParameters.EM_CreatedBy = username;
                    productParameters.EM_CreatedOn = DateTime.Now;
                    db.EM_ProductParams.InsertOnSubmit(productParameters);
                }

                db.SubmitChanges();
                ResetForm();
                gvEMParams.DataBind();
                divForm.Visible = false;
            }
        }
        catch (Exception exp)
        {
            lblErrorMsg.Text = exp.Message;
        }
    }