Exemplo n.º 1
0
        private void DeleteRecordWithCtx(UsersContext ctx, string table, object deletedObj)
        {
            // Question1!!! Ужос, везде код дублируется. Alt+shift+> помогает
            switch (table) // Exlicipt casting to correct class type
            {
            case "awp_users":
            {
                awp_users delObj = (awp_users)deletedObj;
                ctx.awp_users.Attach(delObj);
                ctx.awp_users.Remove(delObj);
                break;
            }

            case "specials":
            {
                special delObj = (special)deletedObj;
                ctx.specials.Attach(delObj);
                ctx.specials.Remove(delObj);
                break;
            }

            default:
                throw new Exception("ERROR\n in DeleteRecordWithCtx, wrong case ");
            }
        }
Exemplo n.º 2
0
        private void UpdateRecordWithCtx(UsersContext ctx, object updatedObj, string tableName)
        {
            // QUESTION как это исправить всё?
            switch (tableName) // Exlicipt casting to correct class type
            {
            case "awp_users":
            {
                awp_users updObj = (awp_users)updatedObj;              // create updated awp_users
                var       oldObj = ctx.awp_users.SingleOrDefault(o => o.id == updObj.id);
                ctx.Entry(oldObj).CurrentValues.SetValues(updatedObj); // get entity's values and update the values
                break;
            }

            case "specials":
            {
                special updObj = (special)updatedObj;
                var     oldObj = ctx.specials.SingleOrDefault(o => o.id == updObj.id);
                ctx.Entry(oldObj).CurrentValues.SetValues(updatedObj);
                break;
            }

            default:
                throw new Exception("ERROR\n in UpdateRecordWithCtx, wrong case ");
            }
        }
Exemplo n.º 3
0
 void Start()
 {
     level       = 0;
     buildings   = special.terrain;
     guarded     = null;
     waterAccess = null;
     roaded      = null;
 }
Exemplo n.º 4
0
 public specialfinalizer(special special = default, ref ptr <funcval> fn = default, System.UIntPtr nret = default, ref ptr <_type> fint = default, ref ptr <ptrtype> ot = default)
 {
     this.special = special;
     this.fn      = fn;
     this.nret    = nret;
     this.fint    = fint;
     this.ot      = ot;
 }
Exemplo n.º 5
0
        public async Task <ActionResult> DeleteConfirmed(string id)
        {
            special special = await db.special.FindAsync(id);

            db.special.Remove(special);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 6
0
        public async Task <ActionResult> Edit([Bind(Include = "special1")] special special)
        {
            if (ModelState.IsValid)
            {
                db.Entry(special).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(special));
        }
Exemplo n.º 7
0
        protected void spesiyal_Click(object sender, EventArgs e)
        {
            special s = new special();

            s.ad       = TextBoxSad.Text;
            s.aciklama = TextBoxSaciklama.Text;
            s.baslik   = TextBoxSbaslik.Text;
            s.resim    = TextBoxSresim.Text;
            db.specials.Add(s);
            db.SaveChanges();
            Response.Redirect("/admin/menu.aspx");
        }
Exemplo n.º 8
0
        public async Task <ActionResult> Create([Bind(Include = "special1")] special special)
        {
            if (ModelState.IsValid)
            {
                db.special.Add(special);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(special));
        }
Exemplo n.º 9
0
        // GET: specials/Edit/5
        public async Task <ActionResult> Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            special special = await db.special.FindAsync(id);

            if (special == null)
            {
                return(HttpNotFound());
            }
            return(View(special));
        }
Exemplo n.º 10
0
        private object GetCorrectObj(DataGridView dgv, int row, string dataBase) // return correct class instance
        {
            var curRowCells     = dgv.Rows[row].Cells;
            var idFromFirstCell = curRowCells[0].Value == null ? 0 : (int)curRowCells[0].Value; // Cell can be null......

            switch (dataBase)
            {
            case "awp_users":
            {
                var obj = new awp_users
                {
                    id          = idFromFirstCell,
                    login_      = (string)curRowCells[1].Value,
                    password    = (byte[])curRowCells[2].Value,
                    salt        = (byte[])curRowCells[2].Tag,
                    id_special  = (int)curRowCells[3].Value,
                    gender      = (string)curRowCells[4].Value,
                    signup_date = (DateTime)curRowCells[5].Value,
                    birth_date  = (DateTime)curRowCells[6].Value
                };
                return(obj);
            }

            case "specials":
            {
                var obj = new special
                {
                    id           = idFromFirstCell,
                    special_code = (string)curRowCells[1].Value,
                    id_role      = (int)curRowCells[2].Value
                };
                return(obj);
            }

            default:
                throw new Exception("Error in GetCorrectObj method");
            }
        }
        public ActionResult Create(Employee_Payroll_Transactions model, FormCollection form, string[] joblevelgrade, string[] JoblevelClass, string[] JobClass)
        {
            try
            {
                var Month      = form["Month"].Split(',');
                var Year       = form["Year"].Split(',');
                var percentage = form["percentage"].Split(',');


                if (joblevelgrade[0] == "1")
                {
                    var Joblevelgrade = dbcontext.Job_level_gradee.ToList();
                    foreach (var item in Joblevelgrade)
                    {
                        int    ID = item.ID;
                        var    min_basic_salary = item.min_basic_salary;
                        double year             = double.Parse(Year[0]);
                        double month            = double.Parse(Month[0]);
                        double Percentage       = double.Parse(percentage[0]);
                        var    Allowance        = (min_basic_salary * Percentage) / 100;
                        double newsalary        = (Allowance + min_basic_salary);
                        var    new_details      = new special_allowance_job_level_grade {
                            Job_level_gradeID = ID, Year = year, Month = month, Percentage = Percentage, Allowance_amount = Allowance, pervious_basic = min_basic_salary, new_basic_sallary = newsalary
                        };
                        dbcontext.special_allowance_job_level_grade.Add(new_details);
                        dbcontext.SaveChanges();
                        item.min_basic_salary = newsalary;
                        dbcontext.SaveChanges();
                    }
                }
                if (JoblevelClass[0] == "1")
                {
                    var jobleveclass = dbcontext.Job_level_class.ToList();
                    foreach (var item in jobleveclass)
                    {
                        int    ID = item.ID;
                        var    min_basic_salary = item.min_basic_salary;
                        double year             = double.Parse(Year[0]);
                        double month            = double.Parse(Month[0]);
                        double Percentage       = double.Parse(percentage[0]);
                        var    Allowance        = (min_basic_salary * Percentage) / 100;
                        double newsalary        = (Allowance + min_basic_salary);
                        var    new_details      = new special_allowance_job_level_class {
                            Job_level_classID = ID, Year = year, Month = month, Percentage = Percentage, Allowance_amount = Allowance, pervious_basic = min_basic_salary, new_basic_sallary = newsalary
                        };
                        dbcontext.special_allowance_job_level_class.Add(new_details);
                        dbcontext.SaveChanges();
                        item.min_basic_salary = newsalary;
                        dbcontext.SaveChanges();
                    }
                }
                if (JobClass[0] == "1")
                {
                    var joblevelsetup = dbcontext.job_level_setup.ToList();
                    foreach (var item in joblevelsetup)
                    {
                        int    ID = item.ID;
                        var    min_basic_salary = item.min_basic_salary;
                        double year             = double.Parse(Year[0]);
                        double month            = double.Parse(Month[0]);
                        double Percentage       = double.Parse(percentage[0]);
                        var    Allowance        = (min_basic_salary * Percentage) / 100;
                        double newsalary        = (Allowance + min_basic_salary);
                        var    new_details      = new special {
                            job_level_setupID = ID, Year = year, Month = month, Percentage = Percentage, Allowance_amount = Allowance, pervious_basic = min_basic_salary, new_basic_sallary = newsalary
                        };
                        dbcontext.special.Add(new_details);
                        dbcontext.SaveChanges();
                        item.min_basic_salary = newsalary;
                        dbcontext.SaveChanges();
                    }
                }

                return(RedirectToAction("index"));
            }
            catch (Exception e)
            {
                return(View(model));
            }
        }
Exemplo n.º 12
0
 public specialprofile(special special = default, ref ptr <bucket> b = default)
 {
     this.special = special;
     this.b       = b;
 }
Exemplo n.º 13
0
        public ActionResult allowance(FormCollection form, int type, int ID)
        {
            try
            {
                TempData["TYPE"] = type;
                TempData["ID"]   = ID;
                ViewBag.id2      = ID;
                if (type == 1)
                {
                    var specialold = dbcontext.special_allowance_job_level_class.Where(m => m.Job_level_classID == ID);
                    dbcontext.special_allowance_job_level_class.RemoveRange(specialold);
                    dbcontext.SaveChanges();
                }
                else if (type == 2)
                {
                    var specialold = dbcontext.special_allowance_job_level_grade.Where(m => m.Job_level_gradeID == ID);
                    dbcontext.special_allowance_job_level_grade.RemoveRange(specialold);
                    dbcontext.SaveChanges();
                }
                else if (type == 3)
                {
                    var specialold = dbcontext.special.Where(m => m.job_level_setupID == ID);
                    dbcontext.special.RemoveRange(specialold);
                    dbcontext.SaveChanges();
                }
                var Year              = form["Year"].Split(char.Parse(","));
                var Month             = form["Month"].Split(char.Parse(","));
                var Percentage        = form["Percentage"].Split(char.Parse(","));
                var Allowance_amount  = form["Allowance_amount1"].Split(char.Parse(","));
                var pervious_basic    = form["pervious_basic"].Split(char.Parse(","));
                var new_basic_sallary = form["new_basic_sallary"].Split(char.Parse(","));
                for (var i = 0; i < Year.Count(); i++)
                {
                    if (type == 1)
                    {
                        var new_record = new special_allowance_job_level_class();
                        if (Year[i] != "" || Month[i] != "" || Percentage[i] != "" || pervious_basic[i] != "" || new_basic_sallary[i] != "")
                        {
                            new_record.Year              = float.Parse(Year[i]);
                            new_record.Month             = float.Parse(Month[i]);
                            new_record.Percentage        = float.Parse(Percentage[i]);
                            new_record.pervious_basic    = float.Parse(pervious_basic[i]);
                            new_record.new_basic_sallary = float.Parse(new_basic_sallary[i]);
                            new_record.Allowance_amount  = float.Parse(Allowance_amount[i]);
                            new_record.Job_level_classID = ID;
                            dbcontext.special_allowance_job_level_class.Add(new_record);
                            dbcontext.SaveChanges();
                        }
                    }
                    else if (type == 2)
                    {
                        var new_record = new special_allowance_job_level_grade();
                        if (Year[i] != "" || Month[i] != "" || Percentage[i] != "" || pervious_basic[i] != "" || new_basic_sallary[i] != "")
                        {
                            new_record.Year              = float.Parse(Year[i]);
                            new_record.Month             = float.Parse(Month[i]);
                            new_record.Percentage        = float.Parse(Percentage[i]);
                            new_record.pervious_basic    = float.Parse(pervious_basic[i]);
                            new_record.new_basic_sallary = float.Parse(new_basic_sallary[i]);
                            new_record.Allowance_amount  = float.Parse(Allowance_amount[i]);
                            new_record.Job_level_gradeID = ID;
                            dbcontext.special_allowance_job_level_grade.Add(new_record);
                            dbcontext.SaveChanges();
                        }
                    }
                    else if (type == 3)
                    {
                        var new_record = new special();
                        if (Year[i] != "" || Month[i] != "" || Percentage[i] != "" || pervious_basic[i] != "" || new_basic_sallary[i] != "")
                        {
                            new_record.Year              = float.Parse(Year[i]);
                            new_record.Month             = float.Parse(Month[i]);
                            new_record.Percentage        = float.Parse(Percentage[i]);
                            new_record.pervious_basic    = float.Parse(pervious_basic[i]);
                            new_record.new_basic_sallary = float.Parse(new_basic_sallary[i]);
                            new_record.Allowance_amount  = float.Parse(Allowance_amount[i]);
                            new_record.job_level_setupID = ID;
                            dbcontext.special.Add(new_record);
                            dbcontext.SaveChanges();
                        }
                    }
                }


                if (type == 2)
                {
                    return(RedirectToAction("index", "Job_level_grade"));
                }
                else if (type == 3)
                {
                    return(RedirectToAction("index", "job_level_setup"));
                }
                else
                {
                    return(RedirectToAction("index"));
                }
            }
            catch (Exception e)
            {
                TempData["TYPE"] = type;
                TempData["ID"]   = ID;
                return(View());
            }
        }