Example #1
1
    protected void Button1_Click(object sender, EventArgs e)
    {
        DataClassesDataContext da = new DataClassesDataContext();

        var result1 = from n in da.user
                     where n.user_name == TextBox3.Text
                     select n.major;
        var result2 = from m in da.project
                      where m.project_num == DropDownList1.Text
                      select m.major;
        foreach (var n in result1)
        {
            foreach (var m in result2)
            {
                if (n != m)
                {
                    ClientScriptManager client = this.ClientScript;
                    client.RegisterStartupScript(this.GetType(), "55", "<script>alert('专业不符!');history.back()</script>");
                    return;
                }
            }
        }
        proposal p = new proposal();
        p.proposal1 = TextBox1.Text;
        p.project_num = DropDownList1.Text;
        p.teacher_name = DropDownList2.Text;
        p.user_name = TextBox3.Text;
        p.proposal_num = TextBox2.Text;
        da.proposal.InsertOnSubmit(p);
        da.SubmitChanges();
        GridView1.DataBind();
    }
Example #2
0
        public ActionResult Index(string username, string password)
        {
            DataClassesDataContext db = new DataClassesDataContext();
            if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))
            {
                return View();
            }

            if (db.Users.Where(u => u.nick == username).Count() < 1)
            {
                db.Users.InsertOnSubmit(new User { nick = username, password = password });
                db.SubmitChanges();
            }

            if (db.Users.Where(u => u.nick == username && u.password == password).Count() > 0)
            {
                Session["login"] = true;
                Session["nick"] = username;
                Session["userid"] = db.Users.Where(u => u.nick == username).First().id;
                Session["type"] = db.Users.Where(u => u.nick == username).First().type;

                return RedirectToAction("Index", "Chat");
            }
            else
            {
                ViewBag.ErrorMessage = "Nicket er ikke tilgjengelig!";
                return View();
            }
        }
    public string BuildEditorNavigation()
    {
        DataClassesDataContext db = new DataClassesDataContext();

        string category_id = "0";
        if (Request.QueryString["category_id"] != null)
        {
            category_id = Request.QueryString["category_id"].ToString();
        }

        string MenuItems = "";
        List<dbCategory> kategori_title = new List<dbCategory>();
        if (Convert.ToInt32(Session["role_access"]) >= 100)
        {
            kategori_title = db.dbCategories.OrderBy(i => i.Id).ToList();
        }
        else
        {
            kategori_title = db.dbCategoryEditors.Where(i => i.UserId == Convert.ToInt32(Session["user_id"])).Select(ce => ce.dbCategory).OrderBy(i => i.Id).ToList();
        }
        foreach (var item in kategori_title)
        {
            string active = (Request.RawUrl.Contains("News.aspx") && category_id == item.Id.ToString() ? " class='active'" : "");
            MenuItems += String.Format("<li{2}><a href='{0}'>{1}</a></li>", "News.aspx?category_id=" + item.Id, item.Title, active);
        }
        return MenuItems;
    }
Example #4
0
        public musicdata[] Getauthor(string author)
        {
            //if (!Hasmusic(author))
            //{
            //    var error = new CustomFaultMsg { Message = "Không có bài nào author là : " + author };
            //    throw new FaultException<CustomFaultMsg>(error, error.Message);
            //}
            using (var musicct = new DataClassesDataContext())
            {
                var song = from music in musicct.SONGs
                           where music.MUSICIAN.IndexOf(author) != -1
                           select new musicdata

                           {
                               Id = music.SONGID.ToString(),
                               aTitle = music.SONGNAME,
                               bAuthor = music.MUSICIAN,
                               Lang = music.LANGUAGE,
                               cSinger = music.SINGER.SINGERNAME,
                               eGenre = music.CATEGORY,
                               dPublish = music.PUBLISH.ToString(),
                               Karaoke = music.KARAOKE.ToString(),
                               Emotion = music.EMOTION.EMOTIONTYPE,
                               Instrument = music.INSTRUMENT,
                               Lyric = music.LYRICS
                           };
                return song.ToList().ToArray();
            }
        }
Example #5
0
    protected void LinkButtonCredit_Click(object sender, EventArgs e)
    {
        PanelCredit.Visible = true;
        PanelAdd.Visible = false;
        PanelLog.Visible = false;
        LinkButtonCredit.Enabled = false;
        LinkButtonAdd.Enabled = true;
        LinkButtonLog.Enabled = true;

        DataClassesDataContext context = new DataClassesDataContext();
        int Userid = Convert.ToInt32(Session["UserId"]);
        var query2 = context.Credits.Where(c => c.UserId == Userid).FirstOrDefault();
        if (query2 != null)
        {
            LabelGiftCredit.Text = query2.GiftCredit.ToString();
            LabelSpendGift.Text = query2.SpentGift.ToString();
            LabelSpentCreadit.Text = query2.SpentCredit.ToString();
            LabelCredit.Text = query2.Credit1.ToString();
        }
        else if (query2 == null)
        {
            LabelGiftCredit.Text = " 0 ";
            LabelSpendGift.Text = " 0 ";
            LabelSpentCreadit.Text = " 0 ";
            LabelCredit.Text = " 0 ";
        }
    }
    public AjaxControlToolkit.Slide[] GetSlides(String contextKey)
    {
        List<AjaxControlToolkit.Slide> slides = new List<AjaxControlToolkit.Slide>();
        if (String.IsNullOrEmpty(contextKey))
            contextKey = "2";

        int artIndex = -1;
        if (int.TryParse(contextKey, out artIndex))
        {
            DataClassesDataContext dtx = new DataClassesDataContext();
            var pics = from p in dtx.Pictures
                       where p.ArticleId == artIndex
                       select new
                       {
                           Id = p.Id,
                           Title = p.Title
                       };

            foreach (var p in pics)
            {
                slides.Add(new AjaxControlToolkit.Slide("sqlimage.axd?name=pic&picId=" + p.Id, p.Title, ""));
            }
        }

        return slides.ToArray();
    }
Example #7
0
 private void initDutyTable()
 {
     DataClassesDataContext db = new DataClassesDataContext();
     FillTable ft = new FillTable(10, 7);
     ft.creatDataArray(db.Duty.ToList());
     ft.fillDataArrayToTable(DutyTable,NoValueDisplay.NoValueString);
 }
    public IQueryable<ndhCareer> getPostingByID(int _id)
    {
        DataClassesDataContext objDataClassesDC = new DataClassesDataContext();

        var postingID = objDataClassesDC.ndhCareers.Where(x => x.id == _id).Select(x => x);
        return postingID;
    }
 public IQueryable<ndhCareer> getPosting()
 {
     DataClassesDataContext objDataClassesDC = new DataClassesDataContext();
     //var allPostings = from x in objDataClassesDC.ndhCareers select x;
     var allPostings = objDataClassesDC.ndhCareers.Select(x => x); //method syntax
     return allPostings;
 }
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        TextBox commentCtrl = (TextBox)CommentsLoginView.FindControl("CommentTextBox");
        if (commentCtrl != null && commentCtrl.Text.Length > 0)
        {
            using (DataClassesDataContext dtx = new DataClassesDataContext())
            {
                int aid = 0;
                MembershipUser mu = Membership.GetUser(HttpContext.Current.User.Identity.Name);
                if (int.TryParse(Context.Request["aid"], out aid))
                {
                    var comment = new Comment()
                    {
                        ArticleId = aid,
                        UserId = (Guid)mu.ProviderUserKey,
                        Body = commentCtrl.Text,
                        Created = System.DateTime.Now
                    };
                    dtx.Comments.InsertOnSubmit(comment);
                    dtx.SubmitChanges();

                    CommentService c = new CommentService();
                    CommentsDataList.DataSource = c.GetComments(aid);
                    CommentsDataList.DataBind();
                }
                commentCtrl.Text = "";
            }
        }
    }
    protected void button1_Click(object sender, EventArgs e)
    {
        if (textbox1.Text.Equals(String.Empty) || textbox2.Text.Equals(String.Empty))
        {
            Label1.Text = "评论内容与验证码不能为空";
            return;
        }
        try
        {
            if (!Request.Cookies["ValiCode"].Value.ToString().Equals(textbox2.Text))
            {
                Label1.Text = "验证码错误";
                return;
            }
            Table_DocumentComment comment = new Table_DocumentComment();
            comment.AccountName = Session["name"].ToString();
            comment.AccountType = Session["type"].ToString();
            comment.Comment = textbox1.Text;
            comment.Date = DateTime.Now;
            comment.DocumentId = (Int32)Session["document"];
            DataClassesDataContext data = new DataClassesDataContext();
            data.Table_DocumentComment.InsertOnSubmit(comment);
            data.SubmitChanges();
            comments.Add(comment);
            textbox1.Text = String.Empty;
            textbox2.Text = String.Empty;
            Label1.Text = String.Empty;

        }
        catch (Exception) { }
    }
        public HttpResponseMessage GetCustomers(SearchFilter searchFilter)
        {
            List<CustomerViewModel> resultList = new List<CustomerViewModel>();
            using (DataClassesDataContext context = new DataClassesDataContext())
            {
                var customers = (from cu in context.CUSTOMERs.Where(cu => cu.DBTimeStamp >= searchFilter.StartDate
                    && cu.DBTimeStamp <= searchFilter.EndDate)
                                 select new CustomerViewModel()
                                     {
                                         customerId = cu.CUSTOMER_ID,
                                         firstname = cu.fname,
                                         lastname = cu.sname,
                                         email = cu.email,
                                         address1 = cu.address1,
                                         address2 = cu.address2,
                                         address3 = cu.address3,
                                         clubNumber = cu.club_no ?? 0,
                                         balance = cu.balance ?? 0
                                     }
                                 ).Take(1000);

                resultList = customers.ToList();
                return this.Request.CreateResponse(HttpStatusCode.OK, resultList);
            }
        }
Example #13
0
 public static List<UsuarioResumido> Usuarios()
 {
     DataClassesDataContext dcdc = new DataClassesDataContext();
     List<UsuarioResumido> usuarios = new List<UsuarioResumido>();
     dcdc.USUARIOs.ToList().ForEach(u => usuarios.Add(new UsuarioResumido(u.CodEmp, u.CodUsu, u.NomUsu, u.IDUSUARIOS, (char)u.ATIVO == 'S' ? true : false, u.Senha)));
     return usuarios;
 }
Example #14
0
    protected void PrzydzielZadanieButton_Click(object sender, EventArgs e)
    {
        List<int> idGrupList = new List<int>();
        for (int i = 0; i < EnableGroupsListView.Items.Count; i++)
        {
            CheckBox chk = EnableGroupsListView.Items[i].FindControl("NazwaCheckBox") as CheckBox;
            if (chk != null && chk.Checked)
            {
                idGrupList.Add((int)EnableGroupsListView.DataKeys[i].Value);
            }
        }

        DataClassesDataContext db = new DataClassesDataContext();
        Zadania zadanie = db.Zadanias.FirstOrDefault(g => g.IdZadania == (int)((DataKey)Session["IdZadania"]).Value);
        foreach (int id in idGrupList)
        {
            ZadaniawGrupach zadaniawGrupach = new ZadaniawGrupach
                                                  {
                                                      Zadania = zadanie,
                                                      IdGrupy = id,
                                                      DataDodania = DateTime.Now
                                                  };
            db.ZadaniawGrupaches.InsertOnSubmit(zadaniawGrupach);
        }
        db.SubmitChanges();
        WczytajListeGrup(db);
        SuccesLabel.Text = "Dodano zadanie do grup/y";
        SuccesLabel.ForeColor = System.Drawing.Color.Green;
    }
Example #15
0
    //student��ʾѧ���˺����� assignment��ʾ��ҵ��
    public List<Answer> GetAnswerList(String student, int assignment)
    {
        DataClassesDataContext da = new DataClassesDataContext();
        var pro = from s in da.Problem
                  where s.assignment == assignment
                  select s.id;
        var answer = from s in da.Answer
                     where s.student == student && s.problem == pro.First()
                     select s;
        AnswerList = new List<Answer>();
        foreach (var p in pro)
        {
            answer = from s in da.Answer
                         where s.student == student && s.problem == p
                         select s;
            foreach (var n in answer)
            {
                AnswerList.Add(n);
            }
        }

        if ((answer.Count()) > 0)
        {
            return AnswerList;
        }
        else
            return null;
    }
Example #16
0
 //��Ӵ�
 public bool AddAnswer(List<Answer> answer)
 {
     DataClassesDataContext da = new DataClassesDataContext();
     da.Answer.InsertAllOnSubmit(answer);
     da.SubmitChanges();
     return true;
 }
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        var List = new List<Student_Registration_Form>();

        var db = new DataClassesDataContext();

        string _accountType, _email, _contactMethod, _campus, _faculty, _course;
        int _phone, _mobile;

        _accountType = ((TextBox) (GridView1.Rows[e.RowIndex].FindControl("textAccType"))).Text;
        _email = ((TextBox) (GridView1.Rows[e.RowIndex].FindControl("textEmail"))).Text;
        //_citizenship = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl("Marital_Status"))).Text;
        _contactMethod = ((TextBox) (GridView1.Rows[e.RowIndex].FindControl("textContact"))).Text;
        _campus = ((TextBox) (GridView1.Rows[e.RowIndex].FindControl("textCampus"))).Text;
        _faculty = ((TextBox) (GridView1.Rows[e.RowIndex].FindControl("textFaculty"))).Text;
        _course = ((TextBox) (GridView1.Rows[e.RowIndex].FindControl("textCourse"))).Text;
        //_phone = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl.("textPhone"))).ToString();
        //_mobile = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl("textMobile"))).Text;

        var update = (from u in db.Student_Registration_Forms
            where u.Accomodition_Type == _accountType
            where u.Email == _email
            //where u.Marital_Status == _citizenship
            where u.Contact == _contactMethod
            where u.campus == _campus
            where u.Faculty == _faculty
            where u.Courses == _course
            select u);


        GridView1.DataSource = List;
        db.SubmitChanges();
        BindGrid();
    }
 public static void Insert(Student_Registration_Form studentToAdd)
     //used by that add student form to add a new record to the db
 {
     var db = new DataClassesDataContext();
     db.Student_Registration_Forms.InsertOnSubmit(studentToAdd);
     db.SubmitChanges();
 }
Example #19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // Set style top link where they stand
            HtmlAnchor a = (HtmlAnchor)Master.FindControl("events");
            if (a != null)
            {
                a.Attributes.Add("class", "topMenuDVLinkActive");
            }

            SetSitemap();

            try
            {
                using (DataClassesDataContext data = new DataClassesDataContext())
                {
                    int ItemCount = int.Parse(data.GetEventsNewsItemCount_En().ToList()[0].ItemCount);
                    AspNetPager1.RecordCount = ItemCount;
                    GetEvents();
                }
            }
            catch (Exception ex)
            {
                // error message here
            }
        }
    }
        public HttpResponseMessage PostPurchasesToXero(SearchFilter searchFilter)
        {
            using (DataClassesDataContext context = new DataClassesDataContext())
            {
                try
                {
                    var purchases = context.XEROPurchases(searchFilter.StartDate, searchFilter.EndDate);
                    foreach (var purchase in purchases)
                    {
                        PurchaseToInvoiceViewModelConverter purchaseConverter = new PurchaseToInvoiceViewModelConverter();
                        try
                        {
                            InvoiceViewModel invoiceViewModel = purchaseConverter.Convert(purchase);
                            purchasesToPostList.Add(invoiceViewModel);
                        }
                        catch (InvoiceValidationException e)
                        {
                            ModelStateDictionary dictionary = errorStringConvertor.Convert(e.Message);
                            return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, e.Message);
                        }
                        catch (SupplierDoesNotExistException e)
                        {
                            ModelStateDictionary dictionary = errorStringConvertor.Convert(e.Message);
                            return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, e.Message);
                        }
                    }
                }
                catch (System.Data.SqlClient.SqlException)
                {
                    ModelStateDictionary dictionary = errorStringConvertor.Convert("To many Purchases in daterange");
                    return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, dictionary);
                }
            }
            try
            {
                xeroLogic.ExportInvoices(purchasesToPostList);
            }
            catch (XeroApiLimitException e)
            {
                ModelStateDictionary dictionary = errorStringConvertor.Convert(e.Message);
                return this.Request.CreateErrorResponse(HttpStatusCode.BadGateway, dictionary);
            }
            catch (XeroException e)
            {
                ModelStateDictionary dictionary = errorStringConvertor.Convert(e.Message);
                return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, dictionary);
            }
            catch (XeroApiValidationException e)
            {
                ModelStateDictionary dictionary = errorStringConvertor.Convert(e.Message);
                return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, dictionary);
            }
            catch (Exception)
            {
                ModelStateDictionary dictionary = errorStringConvertor.Convert("Something went wrong. Please check the data and try again.");
                return this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, dictionary);
            }

            return this.Request.CreateResponse(HttpStatusCode.OK);
        }
 public List<PersonData> GetAll()
 {
     var ctx = WebOperationContext.Current;
     try
     {
         using (var personCtx = new DataClassesDataContext())
         {
             // Set up the query
             var persons = from p in personCtx.Persons
                           orderby p.FirstName
                           select new PersonData
                           {
                               PersonId = p.PersonId,
                               FirstName = p.FirstName,
                               LastName = p.LastName,
                               EmailAddress = p.EmailAddress,
                               Department = p.Department
                           };
             ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.OK;
             return persons.ToList();
         }
     }
     catch
     {
         ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.BadRequest;
         return null;
     }
 }
    public PersonData GetPerson(string personId)
    {
        var ctx = WebOperationContext.Current;
        try
        {
            using (var personCtx = new DataClassesDataContext())
            {
                // Set up the query
                var person = personCtx.Persons.SingleOrDefault(p => p.PersonId == Convert.ToInt32(personId));

                if (person == null)
                {
                    ctx.OutgoingResponse.SetStatusAsNotFound();
                    return null;
                }
                var personData = new PersonData
                                          {
                                              PersonId = person.PersonId,
                                              FirstName = person.FirstName,
                                              LastName = person.LastName,
                                              EmailAddress = person.EmailAddress,
                                              Department = person.Department
                                          };

                ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.OK;
                return personData;
            }
        }
        catch
        {
            ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.BadRequest;
            return null;
        }
    }
    public void DeletePerson(string personId)
    {
        WebOperationContext ctx = WebOperationContext.Current;

        try
        {
            using (var dataContext = new DataClassesDataContext())
            {
                Person person = dataContext.Persons.SingleOrDefault(p => p.PersonId == Convert.ToInt32(personId));
                if (person == null)
                {
                    ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.NotFound;
                    return;
                }

                dataContext.Persons.DeleteOnSubmit(person);
                dataContext.SubmitChanges();

                ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.OK;
                return;
            }
        }
        catch
        {
            ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.BadRequest;
            return;
        }
    }
Example #24
0
 private void initDutyTable(string id)
 {
     DataClassesDataContext db = new DataClassesDataContext();
     FillTable ft = new FillTable(10, 7);
     ft.creatDataArray(db.Duty.Where(dutys=>dutys.assistantID==id).ToList());
     ft.fillDataArrayToTable(DutyTable,NoValueDisplay.Nothing);
 }
Example #25
0
        public static UsuarioResumido Login(int empresa, int usuario, String senha)
        {
            string spwd = new Krypto().EncryptString(senha, AcaoKrypto.cnDECRYPT);

            DataClassesDataContext dcdc = new DataClassesDataContext();
            List<UsuarioResumido> user =    (
                                                from u in dcdc.USUARIOs
                                                join v in dcdc.VENDEDORs on u.CodUsu equals v.CodUsu
                                                where u.CodEmp.Equals(empresa)
                                                where u.CodUsu.Equals(usuario)
                                                where u.Senha.Equals(new Krypto().EncryptString(senha, AcaoKrypto.cnENCRYPT))
                                                where u.ATIVO.Equals('A')
                                                orderby u.NomUsu
                                                select new UsuarioResumido  (
                                                                                u.CodEmp, 
                                                                                u.CodUsu, 
                                                                                u.NomUsu, 
                                                                                u.IDUSUARIOS, 
                                                                                u.ATIVO == 'S' ? true : false, 
                                                                                u.Senha, 
                                                                                v.CodVend, 
                                                                                v.NomVend
                                                                            )
                                            ).ToList();
            if (user.Count == 1)                
            {
                return user[0];
            }
            return null;
        }
Example #26
0
 public static List<EmpresaResumido> GetEmpresa(UsuarioResumido u, int CodEmp)
 {
     DataClassesDataContext dcdc = new DataClassesDataContext();
     List<EmpresaResumido> empresas = new List<EmpresaResumido>();
     dcdc.EMPRESAs.Where(e => e.CodEmp == CodEmp).ToList().ForEach(e => empresas.Add(new EmpresaResumido(e.CodEmp, e.Nome, e.NomeFan, e.CGC, e.InscEst, e.Endereco, e.Cidade, e.Estado, e.Bairro, e.Cep, e.Fone, e.Fax, e.Ramal, e.Numero, e.contato_ant3, e.Email, e.SITE, e.CONTATO, e.CONTATOVENDA, e.EMAILVENDA, e.CODIGOPRASIST == null ? 0 : (int)e.CODIGOPRASIST)));
     return empresas;
 }
Example #27
0
    //***************************** MÉTODO INSERTAR ******************************
    protected void btn_Solicitar_Click(object sender, EventArgs e)
    {
        DataClassesDataContext scc = new DataClassesDataContext();

        solicitud obj_Solicitud = new solicitud();

        try
        {
            //Validacion
            cleanMsgTxt();

            if (validaForm() == 0)
            {
                obj_Solicitud.idCliente = Convert.ToInt32(idCliente);
                obj_Solicitud.cSolicitada = Convert.ToInt32(txt_cSolicitada.Text.Trim());
                obj_Solicitud.idModalidad = Convert.ToByte(txt_modalidad.SelectedValue);
                //obj_Cliente.fechaNac = txt_fn.SelectedDate.ToShortDateString(
                obj_Solicitud.fechaInicio = txt_fInicio.SelectedDate.ToShortDateString();
                obj_Solicitud.fechaFin = txt_fFin.SelectedDate.ToShortDateString();
                obj_Solicitud.ingresoMensual = Convert.ToDecimal(txt_ingresoMe.Text.Trim());
                obj_Solicitud.gastoMensual = Convert.ToDecimal(txt_gastoMens.Text.Trim());
                obj_Solicitud.descripcionCredito = txt_desc.Text.Trim();
                obj_Solicitud.descripcionGarantias = txt_garantias.Text.Trim();
                obj_Solicitud.montoValuado =  Convert.ToDecimal(txt_montoVa.Text.Trim());

                if (Convert.ToDecimal(txt_ingresoMe.Text.Trim()) > Convert.ToDecimal(txt_gastoMens.Text.Trim())
                    & Convert.ToDecimal(txt_montoVa.Text.Trim()) / 3 >= Convert.ToInt32(txt_cSolicitada.Text.Trim()))
                {
                    decimal monto=0;
                    monto=Convert.ToDecimal(txt_montoVa.Text.Trim()) /3;

                    obj_Solicitud.creditoMaximo = monto;

                    obj_Solicitud.estatus = "Aceptado";
                }
                else {

                    decimal monto = 0;
                    monto = Convert.ToDecimal(txt_montoVa.Text.Trim()) / 3;

                    obj_Solicitud.creditoMaximo = monto;
                    obj_Solicitud.estatus = "Rechazado";
                }

                scc.solicitud.InsertOnSubmit(obj_Solicitud); //uso del metodo

                scc.SubmitChanges(); //cambioss

                lbl_Mensaje.Text = "Su solicitud ha sido registrada";

            }

        }
        catch (Exception ex)
        {
            lbl_Mensaje.Text = "ERROR - " + ex.Message.ToString();

        }
    }
Example #28
0
        public static List<FormaPagtoResumido> ListarFormasPagto(UsuarioResumido Usuario)
        {
            DataClassesDataContext dcdc = new DataClassesDataContext();

            /* SELECT * FROM ITCONPAGTO, FORMAPAGTO, TIPOPRAZO  
             * WHERE 
             *      ITCONPAGTO.CodFrmPgt = FORMAPAGTO.CodFrmPgt  AND 
             *      ITCONPAGTO.CodTipPrz = TIPOPRAZO.CodTipPrz  and 
             *      codemp = 1 AND 
             *      FILTROVENDA = 1 
             *      ORDER BY FORMAPAGTO.DesFrmPgt, FORMAPAGTO.CodFrmPgt
             * 
             */

            var dados = (from it in dcdc.ITCONPAGTOs 
                         join fp in dcdc.FORMAPAGTOs on it.CodFrmPgt equals fp.CodFrmPgt
                         join tp in dcdc.TIPOPRAZOs on it.CodTipPrz equals tp.CodTipPrz
                         where it.CodEmp.Equals(Usuario.CodEmp)
                         where fp.FiltroVenda.Equals(1)
                         orderby fp.DesFrmPgt
                         orderby fp.CodFrmPgt

                         select new FormaPagtoResumido  (
                                                            it.CodEmp, 
                                                            fp.CodFrmPgt, 
                                                            tp.CodTipPrz, 
                                                            fp.DesFrmPgt, 
                                                            tp.DesTipPrz,
                                                            String.Empty,
                                                            String.Empty,
                                                            fp.GeraParcelas.ToString()
                                                        )).ToList();




            //dcdc.Dispose();
            String vrGeraParcelas = "";
            String vrFormaPagto ="";

            foreach (FormaPagtoResumido item in dados)
            {
                if (vrGeraParcelas == "S" && item.CodFrmPgt.ToString() == vrFormaPagto)
                {
                    vrGeraParcelas = item.GeraParcelas.ToString();                    
                } 
                else 
                {
                    item.ValorCombo = (item.CodFrmPgt.ToString() + "|" + item.CodTipPrz.ToString().Trim());
                    item.LinhaCombo = (item.CodFrmPgt.ToString("000") + " - " + item.DesFrmPgt.Trim());

                    vrFormaPagto = item.CodFrmPgt.ToString();
                    vrGeraParcelas = item.GeraParcelas.ToString(); 
                }
            }

            dcdc.Dispose();
            return dados;
        }
Example #29
0
 public static List<UsuarioResumido> Usuario(int codEmp, int codUsu)
 {
     DataClassesDataContext dcdc = new DataClassesDataContext();
     List<UsuarioResumido> usuarios = new List<UsuarioResumido>();
     
     dcdc.USUARIOs.Where(u => u.CodEmp == codEmp && u.CodUsu == codUsu).ToList().ForEach(u => usuarios.Add(new UsuarioResumido(u.CodEmp, u.CodUsu, u.NomUsu, u.IDUSUARIOS, String.IsNullOrEmpty(u.ATIVO.ToString()) || u.ATIVO.ToString()=="N" ? false : true, u.Senha)));
     return usuarios;
 }
 /// <summary>
 /// Singleton pattern to get the DataContext Object
 /// </summary>
 /// <returns>DatabaseClassesDataContext</returns>
 public DataClassesDataContext getDataContext()
 {
     if (DataContext == null)
     {
         DataContext = new DataClassesDataContext();
     }
     return DataContext;
 }
Example #31
0
    private void binddata()
    {
        try {
            var DC = new DataClassesDataContext();

            var str = from obj in DC.tblFeedbacks
                      join obj1 in DC.tblClients
                      on obj.ClientID equals obj1.ClientID
                      where obj.ClientID == obj1.ClientID && obj.Email == obj1.Email
                      select new
            {
                Data = obj1.FirstName + " " + obj1.LastName,
                obj1.ContactNo,
                obj1.ClientID,
                obj.FeedBackID,
                obj.Email,
                obj.IsNotify
            };

            //var str = from obj in DC.tblFeedbacks
            //            where obj.IsNotify == true
            //          select new
            //          {

            //              CBy = (from ob in DC.tblClients
            //                     where ob.Email == obj.Email
            //                     select new
            //                     {
            //                         Data = ob.FirstName + " " + ob.LastName
            //                     }).Take(1).SingleOrDefault().Data,
            //              //obj.ClientID,
            //              obj.CreatedOn,
            //              obj.FeedBackID,
            //              obj.Email,
            //              obj.IsNotify,
            //              obj.Description


            //          };
            DC.SubmitChanges();
            rptfb.DataSource = str;
            rptfb.DataBind();
            tblAdmin AdminData = DC.tblAdmins.Single(ob => ob.AdminID == Convert.ToInt32(Session["AdminID"]));
            if (AdminData.IsUpdate == false)
            {
                foreach (RepeaterItem item in rptfb.Items)
                {
                    PlaceHolder PlaceHolderActive = (PlaceHolder)item.FindControl("PlaceHolderActive");
                    PlaceHolderActive.Visible = false;
                }
                PlaceHolderActiveHeader.Visible = false;
            }
        }
        catch (Exception ex)
        {
            int    session    = Convert.ToInt32(Session["AdminID"].ToString());
            string PageName   = System.IO.Path.GetFileName(Request.Url.AbsolutePath);
            string MACAddress = GetMacAddress();
            AddErrorLog(ref ex, PageName, "Admin", 0, session, MACAddress);
            ClientScript.RegisterStartupScript(GetType(), "abc", "alert('Something went wrong! Try again');", true);
        }
    }
Example #32
0
 /// <summary>
 /// 通用資料倉儲
 /// </summary>
 /// <param name="dataContext">資料實體</param>
 /// <returns>資料倉儲介面</returns>
 public static ITidal TidalRepository(DataClassesDataContext dataContext = null)
 {
     return(new TidalRepository(dataContext));
 }
Example #33
0
 /// <summary>
 /// 通用資料倉儲
 /// </summary>
 /// <param name="dataContext">資料實體</param>
 /// <returns>資料倉儲介面</returns>
 public static IBusStop BusStopRepository(DataClassesDataContext dataContext = null)
 {
     return(new BusStopRepository(dataContext));
 }
Example #34
0
    protected void btnImport_Click(object sender, EventArgs e)
    {
        if (fuFile.HasFile)
        {
            lblSuccess.Text = "";
            lblError.Text   = "";
            try
            {
                DataClassesDataContext db = new DataClassesDataContext();
                fuFile.SaveAs(Server.MapPath("~/assets/import/product/" + fuFile.FileName));
                StreamReader sr = new StreamReader(Server.MapPath("~/assets/import/product/" + fuFile.FileName));
                try
                {
                    CsvReader csvread = new CsvReader(sr);
                    csvread.Configuration.Delimiter       = ";";
                    csvread.Configuration.HasHeaderRecord = false;
                    char[] delimeter = { ',' };

                    List <CSV_Product> record = csvread.GetRecords <CSV_Product>().ToList();
                    int totalRead             = 0;
                    int totalInsert           = 0;
                    int totalUpdate           = 0;
                    foreach (var item in record)
                    {
                        totalRead++;
                        #region KALO Artikel Master PRODUCT BELUM ADA
                        if (IsProductExists(item.ReferenceCodeProduct) == 0)
                        {
                            string[] category       = item.Category.Split(delimeter);
                            int[]    listIDCategory = ImportCategory(category);
                            int      idSize         = ImportSize(item.Size);
                            int      idColor        = ImportColor(item.Color, item.HexaColor);
                            int      idProduct      = ImportProduct(listIDCategory[0], item.Name, item.ReferenceCodeProduct, item.Price, item.Weight, item.Active, item.Description, item.ShortDescription, item.MetaTitle, item.MetaDescription, item.MetaKeyword);

                            //INSERT COMBINATION COLOR
                            ImportCombination(idProduct, item.ReferenceCodeCombination, item.Price, item.Price, item.Price, item.Price, item.Price, item.Weight, item.Weight, item.Quantity, idColor, idSize);
                            totalInsert++;
                            //INSERT Category Product
                            for (int i = 1; i < listIDCategory.Length; i++)
                            {
                                TBProduct_Category _newData = new TBProduct_Category();
                                _newData.IDCategory     = listIDCategory[i];
                                _newData.IDProduct      = idProduct;
                                _newData.IsDefault      = i == listIDCategory.Length - 1 ? true : false;
                                _newData.DateInsert     = DateTime.Now;
                                _newData.DateLastUpdate = DateTime.Now;
                                db.TBProduct_Categories.InsertOnSubmit(_newData);
                                db.SubmitChanges();
                            }
                        }
                        #endregion
                        else
                        {
                            totalUpdate++;
                            int      idProduct      = IsProductExists(item.ReferenceCodeProduct);
                            string[] category       = item.Category.Split(delimeter);
                            int[]    listIDCategory = ImportCategory(category);
                            int      idSize         = ImportSize(item.Size);
                            int      idColor        = ImportColor(item.Color, item.HexaColor);
                            //INSERT COMBINATION COLOR
                            ImportCombination(idProduct, item.ReferenceCodeCombination, item.Price, item.Price, item.Price, item.Price, item.Price, item.Weight, item.Weight, item.Quantity, idColor, idSize);
                        }
                        //if (db.TBProvinces.Where(X => X.IDProvince == item.IDProvince).FirstOrDefault() != null)
                        //{
                        //    if (db.TBCities.Where(x => x.Name.ToLower() == item.Name.ToLower()).FirstOrDefault() == null)
                        //    {
                        //        TBCity newCity = new TBCity { IDProvince = item.IDProvince, Name = item.Name, CityType = item.CityType, Deflag = false, DateInsert = DateTime.Now, DateLastUpdate = DateTime.Now };
                        //        db.TBCities.InsertOnSubmit(newCity);
                        //        totalInsert++;
                        //    }
                        //    else
                        //    {
                        //        lblSuccess.Text += item.Name + "--";
                        //    }
                        //}
                        //else
                        //{
                        //    lblSuccess.Text += item.Name + "(" + item.IDProvince + ")--";
                        //}
                    }

                    sr.Close();
                    lblSuccess.Text += totalRead + " row(s) read, " + totalInsert + " row(s) inserted, " + totalUpdate + " row(s) updated";
                    alertError.Style.Add(HtmlTextWriterStyle.Display, "none");
                    alertSuccess.Style.Add(HtmlTextWriterStyle.Display, "block");
                }
                catch (Exception ex)
                {
                    sr.Close();
                    lblError.Text = ex.Message;
                    alertError.Style.Add(HtmlTextWriterStyle.Display, "block");
                    alertSuccess.Style.Add(HtmlTextWriterStyle.Display, "none");
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
                alertError.Style.Add(HtmlTextWriterStyle.Display, "block");
                alertSuccess.Style.Add(HtmlTextWriterStyle.Display, "none");
            }
        }
    }
Example #35
0
        static void Main(string[] args)
        {
            var logPath = cfg.Default.FaviconFolder + "log.txt";

            try {
                var sites      = GetSites();
                var stackSites = from s in sites select new StackSite()
                {
                    Description = s.Description, KeyName = s.Name.Replace(" ", ""), Name = s.Name, State = s.State.ToString(), Url = s.SiteUrl
                };
                DataClassesDataContext ctx = new DataClassesDataContext(cfg.Default.DefaultConnectionString);

                foreach (var stackSite in ctx.StackSites)
                {
                    ctx.StackSites.DeleteOnSubmit(stackSite);
                }
                ctx.SubmitChanges();

                if (!Directory.Exists(cfg.Default.FaviconFolder))
                {
                    Directory.CreateDirectory(cfg.Default.FaviconFolder);
                }
                else
                {
                    foreach (var file in Directory.GetFiles(cfg.Default.FaviconFolder))
                    {
                        File.Delete(file);
                    }
                }
                foreach (var stackSite in stackSites)
                {
                    File.WriteAllText(logPath, stackSite.Name + "\n");
                    Console.WriteLine(stackSite.Name);
                    try {
                        using (var wc = new WebClient()) {
                            byte[] faviconBytes = wc.DownloadData(stackSite.Url + "/favicon.ico");
                            string faviconPath  = cfg.Default.FaviconFolder + stackSite.KeyName;

                            File.WriteAllBytes(faviconPath + ".ico", faviconBytes);

                            using (var faviconStream = new FileStream(faviconPath + ".ico", FileMode.Open, FileAccess.Read)) {
                                using (var faviconImage = Image.FromStream(faviconStream)) {
                                    using (var outputStream = new MemoryStream()) {
                                        faviconImage.Save(outputStream, ImageFormat.Png);
                                        File.WriteAllBytes(faviconPath + ".png", outputStream.ToArray());
                                    }
                                }
                            }
                        }
                    } catch (Exception e) {
                        File.WriteAllText(logPath, stackSite.Name + " - " + e.Message + "\n");
                        Console.WriteLine(stackSite.Name + " - " + e.Message);
                    }
                    ctx.StackSites.InsertOnSubmit(stackSite);
                }
                ctx.SubmitChanges();
                File.WriteAllText(logPath, "Done");
                Console.WriteLine("Done");
                Console.Read();
            } catch (Exception e) {
                File.WriteAllText(logPath, e.Message);
                Console.WriteLine(e.Message);
            }
        }
Example #36
0
 /// <summary>
 /// 通用資料倉儲
 /// </summary>
 /// <param name="dataContext">資料實體</param>
 /// <returns>資料倉儲介面</returns>
 public static IRealTime RealTimeRepository(DataClassesDataContext dataContext = null)
 {
     return(new RealTimeRepository(dataContext));
 }
 public void Setup()
 {
     BaseSetup();
     Linq2SqlContext = new DataClassesDataContext(_connection);
 }
Example #38
0
    private void bindata()
    {
        try
        {
            var DC  = new DataClassesDataContext();
            var str = from obj in DC.tblSPPackages
                      //where obj.IsActive == true
                      select new
            {
                img = (from ob in DC.tblPackages
                       where ob.PackagesID == obj.PackagesId
                       select new
                {
                    Data = (from o1 in DC.tblImages
                            where o1.ImagesID == ob.ImageID
                            select new
                    {
                        str = o1.Name
                    }).Take(1).SingleOrDefault().str,
                }).Take(1).SingleOrDefault().Data,

                CBy = (from ob in DC.tblAdmins
                       where ob.AdminID == obj.CreatedBy
                       select new
                {
                    Data = ob.FirstName + " " + ob.LastName
                }).Take(1).SingleOrDefault().Data,

                SPN = (from ob in DC.tblServiceProviders
                       where ob.ServiceProviderID == obj.ServiceProviderID
                       select new
                {
                    Data = ob.FirstName + " " + ob.LastName
                }).Take(1).SingleOrDefault().Data,
                PN = (from ob in DC.tblPackages
                      where ob.PackagesID == obj.PackagesId
                      select new
                {
                    Data = ob.Name
                }).Take(1).SingleOrDefault().Data,
                //obj.Image,
                obj.SPPackagesID,
                obj.Start_Date,
                obj.End_Date,
                obj.CreatedBy,
                obj.IsActive
            };
            DC.SubmitChanges();
            rptSP.DataSource = str;
            rptSP.DataBind();
            tblAdmin AdminData = DC.tblAdmins.Single(ob => ob.AdminID == Convert.ToInt32(Session["AdminID"]));
            if (AdminData.IsUpdate == false)
            {
                foreach (RepeaterItem item in rptSP.Items)
                {
                    PlaceHolder PlaceHolderActive = (PlaceHolder)item.FindControl("PlaceHolderActive");
                    PlaceHolderActive.Visible = false;
                }
                PlaceHolderActiveHeader.Visible = false;
            }
        }
        catch (Exception ex)
        {
            int    session    = Convert.ToInt32(Session["AdminID"].ToString());
            string PageName   = System.IO.Path.GetFileName(Request.Url.AbsolutePath);
            string MACAddress = GetMacAddress();
            AddErrorLog(ref ex, PageName, "Admin", 0, session, MACAddress);
            ClientScript.RegisterStartupScript(GetType(), "abc", "alert('Something went wrong! Try again');", true);
        }
    }
Example #39
0
 /// <summary>
 /// 通用資料倉儲
 /// </summary>
 /// <param name="dataContext">資料實體</param>
 /// <returns>資料倉儲介面</returns>
 public static IUBike UBikeRepository(DataClassesDataContext dataContext = null)
 {
     return(new UBikeRepository(dataContext));
 }
Example #40
0
    protected void rptSP_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try {
            var DC = new DataClassesDataContext();

            int ID = Convert.ToInt32(e.CommandArgument);


            if (e.CommandName == "Active")
            {
                tblSPPackage result = (from u in DC.tblSPPackages
                                       where u.SPPackagesID == ID
                                       select u).Single();

                if (result.IsActive == true)
                {
                    result.IsActive = false;
                }
                else
                {
                    result.IsActive = true;
                }
                DC.SubmitChanges();
            }
            else if (e.CommandName == "View")
            {
                var str = from obj in DC.tblSPPackages
                          //                  //where obj.IsActive == true
                          where obj.SPPackagesID == Convert.ToInt32(e.CommandArgument)
                          select new
                {
                    img = (from ob in DC.tblPackages
                           where ob.PackagesID == obj.PackagesId
                           select new
                    {
                        Data = (from o1 in DC.tblImages
                                where o1.ImagesID == ob.ImageID
                                select new
                        {
                            str = o1.Name
                        }).Take(1).SingleOrDefault().str,
                    }).Take(1).SingleOrDefault().Data,

                    CBy = (from ob in DC.tblAdmins
                           where ob.AdminID == obj.CreatedBy
                           select new
                    {
                        Data = ob.FirstName + " " + ob.LastName
                    }).Take(1).SingleOrDefault().Data,
                    PN = (from ob in DC.tblPackages
                          where ob.PackagesID == obj.PackagesId
                          select new
                    {
                        Data = ob.Name
                    }).Take(1).SingleOrDefault().Data,
                    price = (from ob in DC.tblPackages
                             where ob.PackagesID == obj.PackagesId
                             select new
                    {
                        Data = ob.Price
                    }).Take(1).SingleOrDefault().Data,
                    Du = (from ob in DC.tblPackages
                          where ob.PackagesID == obj.PackagesId
                          select new
                    {
                        Data = ob.Duration
                    }).Take(1).SingleOrDefault().Data,

                    Des = (from ob in DC.tblPackages
                           where ob.PackagesID == obj.PackagesId
                           select new
                    {
                        Data = ob.Description
                    }).Take(1).SingleOrDefault().Data,
                    //obj.Image,
                    obj.SPPackagesID,
                    obj.Start_Date,
                    obj.End_Date,
                    obj.CreatedBy,
                    obj.IsActive
                };
                rptViewDetail.DataSource = str;
                rptViewDetail.DataBind();
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal({backdrop:'static', keyboard: false});", true);
                //    upModal.Update();
            }
            bindata();
        }
        catch (Exception ex)
        {
            int    session    = Convert.ToInt32(Session["AdminID"].ToString());
            string PageName   = System.IO.Path.GetFileName(Request.Url.AbsolutePath);
            string MACAddress = GetMacAddress();
            AddErrorLog(ref ex, PageName, "Admin", 0, session, MACAddress);
            ClientScript.RegisterStartupScript(GetType(), "abc", "alert('Something went wrong! Try again');", true);
        }
    }
Example #41
0
 /// <summary>
 /// 倉儲建構子
 /// </summary>
 /// <param name="context">實體資料集合</param>
 public ParkingRepository(DataClassesDataContext context = null)
 {
     this._db = (context == null ? new DataClassesDataContext() : context);
 }
Example #42
0
 /// <summary>
 /// 倉儲建構子
 /// </summary>
 public ParkingRepository()
 {
     this._db = new DataClassesDataContext();
 }
Example #43
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var        DC          = new DataClassesDataContext();
        tblTask    Data        = DC.tblTasks.Single(ob => ob.TaskID == Convert.ToInt32(Session["TaskID"]));
        tblModule  ModuleData  = DC.tblModules.Single(ob => ob.ModuleID == Data.ModuleID);
        tblProject ProjectData = DC.tblProjects.Single(ob => ob.ProjectID == ModuleData.ProjectID);

        lblProName.Text        = ProjectData.Title;
        txtTaskName.Text       = Data.Title;
        rptAddSkill.DataSource = ProjectObject.ViewSkill();
        rptAddSkill.DataBind();
        if (Data.State == 1)
        {
            ddState.SelectedIndex = 0;
        }
        else if (Data.State == 2)
        {
            ddState.SelectedIndex = 1;
        }
        else if (Data.State == 3)
        {
            ddState.SelectedIndex = 2;
        }
        else if (Data.State == 4)
        {
            ddState.SelectedIndex = 3;
        }
        else
        {
            ddState.SelectedIndex = 0;
        }

        if (Data.Priority == 1)
        {
            ddPriority.SelectedIndex = 1;
        }
        else if (Data.Priority == 2)
        {
            ddPriority.SelectedIndex = 2;
        }
        else if (Data.Priority == 3)
        {
            ddPriority.SelectedIndex = 3;
        }
        else if (Data.Priority == 4)
        {
            ddPriority.SelectedIndex = 4;
        }
        else if (Data.Priority == 5)
        {
            ddPriority.SelectedIndex = 5;
        }
        else
        {
            ddPriority.SelectedIndex = 0;
        }

        if (Data.Risk == 1)
        {
            ddRisk.SelectedIndex = 1;
        }
        else if (Data.Risk == 2)
        {
            ddRisk.SelectedIndex = 2;
        }
        else if (Data.Risk == 3)
        {
            ddRisk.SelectedIndex = 3;
        }
        else
        {
            ddRisk.SelectedIndex = 0;
        }

        //lblDDate.Text = Convert.ToDateTime(Data.DeadlineDate).ToShortDateString();
        //txtCkEditor.Text = Data.Description;
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        //Save change request
        DataClassesDataContext dataContext = new DataClassesDataContext();

        string aan = Users.getUserByUserName(HttpContext.Current.User.Identity.Name).AAN;
        var    _alreadyRequested = from _requested in dataContext.tblChangeRequests where _requested.AAN == aan select _requested;

        if (_alreadyRequested.FirstOrDefault() != null)
        {
            lblStatus.Text = "You have already submitted a change request!";
            return;
        }

        string firstPreferrence = string.Empty;
        string secondPreference = string.Empty;
        string thirdPreference  = string.Empty;

        foreach (GridViewRow row in grdQuarters.Rows)
        {
            RadioButton radPriority1 = row.FindControl("radPriority1") as RadioButton;
            RadioButton radPriority2 = row.FindControl("radPriority2") as RadioButton;
            RadioButton radPriority3 = row.FindControl("radPriority3") as RadioButton;

            if (firstPreferrence == string.Empty && radPriority1.Checked)
            {
                firstPreferrence = ((Label)row.FindControl("lblQuarterNumber")).Text;
            }

            if (secondPreference == string.Empty && radPriority2.Checked)
            {
                secondPreference = ((Label)row.FindControl("lblQuarterNumber")).Text;
            }

            if (thirdPreference == string.Empty && radPriority3.Checked)
            {
                thirdPreference = ((Label)row.FindControl("lblQuarterNumber")).Text;
            }
        }

        if (string.IsNullOrEmpty(firstPreferrence) &&
            string.IsNullOrEmpty(secondPreference) &&
            string.IsNullOrEmpty(thirdPreference))
        {
            lblStatus.Text = "Please select a valid preference.";
            return;
        }

        tblChangeRequest changeRequest = new tblChangeRequest();

        changeRequest.AAN             = aan;
        changeRequest.FirstPerference = firstPreferrence;
        if (string.IsNullOrEmpty(secondPreference))
        {
            changeRequest.SecondPerference = string.Empty;
        }
        else
        {
            changeRequest.SecondPerference = secondPreference;
        }
        if (string.IsNullOrEmpty(thirdPreference))
        {
            changeRequest.ThirdPerference = string.Empty;
        }
        else
        {
            changeRequest.ThirdPerference = thirdPreference;
        }

        changeRequest.QuarterCategory  = Convert.ToInt32(categoryId);
        changeRequest.QuarterNumber    = lblAllottedQuarter.Text;
        changeRequest.Name             = lblFullname.Text;
        changeRequest.dateofsubmission = DateTime.Now;
        dataContext.tblChangeRequests.InsertOnSubmit(changeRequest);
        dataContext.SubmitChanges();

        Response.Redirect("~/user/confirmation.aspx");
    }
Example #45
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        SearchReport.CreateReportReset(); // takes off the selected report in ddlCreateReport

        // get the last Report ID
        string   query = "SELECT MAX(ReportId) AS ReportId FROM dbo.Report_MerrylandsRSLReception";
        int      lastRId, result, returnFlag = 2;
        DateTime temp, date = DateTime.Parse(DateTime.Now.ToShortDateString());

        Report.ErrorMessage = "";

        con.Open();
        SqlCommand getRId = new SqlCommand(query, con);

        try
        {
            lastRId = (int)getRId.ExecuteScalar();
            // add plus one to the current report id to be used in this report
            lastRId += 1;
        }
        catch
        {
            lastRId = 6000001;
        }
        con.Close();

        Report.LastReportId = lastRId.ToString();

        if (txtDatePicker.Text == "")
        {
            Report.ErrorMessage = Report.ErrorMessage + "\\n* Shift Date shouldn't be empty.";
            txtDatePicker.Focus();
            returnFlag = 1;
        }
        else if (!DateTime.TryParse(txtDatePicker.Text, out temp))
        {
            Report.ErrorMessage = Report.ErrorMessage + "\\n* Shifts Date entry is not in date format please select an appropriate date.";
            txtDatePicker.Focus();
            returnFlag = 1;
        }
        else if (DateTime.TryParse(txtDatePicker.Text, out temp))
        {
            // compare selected date to current date
            result = DateTime.Compare(DateTime.Parse(DateTime.Parse(txtDatePicker.Text).ToShortDateString()), date);
            if (result > 0)
            {
                Report.ErrorMessage = Report.ErrorMessage + "\\n* DATE MUST BE BEFORE CURRENT DATE.";
                txtDatePicker.Focus();
                returnFlag = 1;
            }
        }

        //if (txtSpecialComments.Text == "")
        //{
        //    Report.ErrorMessage = Report.ErrorMessage + "\\n* COVID-19 section shouldn't be empty.";
        //    txtSpecialComments.Focus();
        //    returnFlag = 1;
        //}

        if (returnFlag == 1)
        {
            ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", "alert(\"" + Report.ErrorMessage + "\");", true);
            return;
        }

        // change the format of the shift date to timestamp format
        DateTime shift_date  = DateTime.Parse(txtDatePicker.Text);
        string   shift_tDate = shift_date.ToString("yyyyMMdd");

        // separate the shift date day of week value
        string shift_DOW = shift_date.DayOfWeek.ToString();

        // change the format of the entry date to timestamp format
        DateTime entry_date = DateTime.Now;

        // pop a message if shift is unchanged
        if (ddlShift.SelectedItem.Value == "-1")
        {
            showAlert("Please select Shift.");
            ddlShift.Focus();
            return;
        }

        // get staff's id
        string cmdText  = "SELECT StaffId FROM Staff WHERE Username = '******'",
               variable = "getStaff";

        readFiles(cmdText, variable);

        // insert data to table
        using (DataClassesDataContext dc = new DataClassesDataContext())
        {
            Report_MerrylandsRSLReception dm = new Report_MerrylandsRSLReception();
            dm.ReportId        = Int32.Parse(Report.LastReportId);
            dm.RCatId          = 6; // MR Reception Category
            dm.StaffId         = Int32.Parse(Session["currentStaffId"].ToString());
            dm.StaffName       = UserCredentials.DisplayName;
            dm.ShiftId         = Int32.Parse(ddlShift.SelectedItem.Value);
            dm.ShiftDate       = shift_date.Date;
            dm.ShiftDOW        = shift_DOW;
            dm.EntryDate       = entry_date;
            dm.Report_Table    = "Report_MerrylandsRSLReception";
            dm.AuditVersion    = 1;
            dm.ReportStat      = "Awaiting Completion";
            dm.Report_Version  = 2; // current version
            dm.ReadByList      = "," + UserCredentials.StaffId + ",";
            dm.SignInSlip      = txtSignInSlip.Text.Replace("\n", "<br />").Replace("'", "^");
            dm.Refusals        = txtRefusals.Text.Replace("\n", "<br />").Replace("'", "^");
            dm.EventsField     = txtEventsField.Text.Replace("\n", "<br />").Replace("'", "^");
            dm.GeneralComments = txtGeneralComms.Text.Replace("\n", "<br />").Replace("'", "^");
            dm.SpecialComments = txtSpecialComments.Text.Replace("\n", "<br />").Replace("'", "^");
            dc.Report_MerrylandsRSLReceptions.InsertOnSubmit(dm);
            dc.SubmitChanges();
        }

        //log the create activity
        RunStoredProcedure rsp = new RunStoredProcedure();

        try
        {
            rsp.Log(4, Int32.Parse(Report.LastReportId));
        }
        catch { }

        //showAlert("Report Submitted.");
        //Response.Redirect("Default.aspx", false);
        ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect",
                                            "alert('Report Submitted.'); window.location='" +
                                            Request.ApplicationPath + "Default.aspx';", true);
        SearchReport.SetAccordion     = "1";
        SearchReport.RunOnStart       = true;
        SearchReport.FromCreateReport = true;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["applicationId"] == null)
        {
            Response.Redirect("~/user/application.aspx");
        }
        else if (Request["applicationId"] != null)
        {
            applicationId = Convert.ToString(Request["applicationId"]);
        }
        tbAllotmentApplication application = AllotementApplications.GetApplication(Convert.ToInt64(applicationId));

        categoryId = application.QuarterCategory.Value;

        if (!Page.IsPostBack)
        {
            tblUser user = Users.getUser(application.Userid.Value);

            DateTime?dt = null;
            //Check if user is debarred or deferred
            if (Users.IsUserDeferred(user.Id, out dt))
            {
                Response.Redirect("~/user/notallowed.aspx");
            }

            if (Users.IsUserDebarred(user.Id, out dt))
            {
                Response.Redirect("~/user/notallowed.aspx?debar=true");
            }


            lblFullname.Text        = user.fullName;
            lblDesignation.Text     = Users.GetUserDesignation(user.Id);
            lblAllottedQuarter.Text = "N/A";

            var allottee = Allottee.GetAllotteeByAAN(user.AAN);
            if (allottee != null && (allottee.Status.Value == ((int)AllotementStatus.Possessed) || allottee.Status.Value == ((int)AllotementStatus.ChangeRequested)))
            {
                string allottedQuarter = allottee.QuarterNumber;
                lblAllottedQuarter.Text = allottedQuarter;
            }

            if (application.QuarterCategory.HasValue && !Quarters.IsQuarterCategoryActive(application.QuarterCategory.Value))
            {
                submissionClosedPanel.Visible = true;
                return;
            }
            else
            {
                //Quarter category is active
                if (lblAllottedQuarter.Text == "N/A" || application.Status == (int)ApplicationStatus.Pending) //New allottment cases
                {
                    if (application.MedicalCategory.HasValue && application.MedicalCategory.Value >= 0)       //Medical grounds
                    {
                        applyForQuarterMedicalGroundsPanel.Visible = true;
                        btnNewAllottmentMedical.Enabled            = true;
                    }
                    else
                    {
                        applyForQuarterPanel.Visible = true;
                        btnNewAllottment.Enabled     = true;
                    }
                }
                else
                {
                    if (application.MedicalCategory.HasValue && application.MedicalCategory.Value >= 0) //Medical grounds
                    {
                        applyForQuarterMedicalGroundsPanel.Visible = true;
                        btnChangeRequestMedical.Enabled            = true;
                    }
                    else
                    {
                        applyForQuarterPanel.Visible = true;
                        btnChangeRequest.Enabled     = true;
                    }
                }

                DataClassesDataContext dataContext = new DataClassesDataContext();

                string aan = Users.getUserByUserName(HttpContext.Current.User.Identity.Name).AAN;
                var    _alreadyRequested = from _requested in dataContext.tblChangeRequests
                                           where _requested.AAN == aan &&
                                           (_requested.Status == (int)ChangeRequestStatus.Pending ||
                                            _requested.Status == (int)ChangeRequestStatus.Approved)
                                           select _requested;

                if (_alreadyRequested.FirstOrDefault() != null)
                {
                    var changeRequest = _alreadyRequested.FirstOrDefault();
                    pnlChangeRequestInformation.Visible = true;
                    btnChangeRequest.Enabled            = false;
                    btnChangeRequestMedical.Enabled     = false;

                    lblRequestID.Text        = changeRequest.Id.ToString();
                    lblFirstPreference.Text  = changeRequest.FirstPerference ?? "N/A";
                    lblSecondPreference.Text = changeRequest.SecondPerference ?? "N/A";
                    lblThirdPreference.Text  = changeRequest.ThirdPerference ?? "N/A";
                }
                else
                {
                    pnlChangeRequestInformation.Visible = false;
                }
            }
            BindData();
        }

        changeRequests            = new DataClassesDataContext().tblChangeRequests.ToList();
        grdQuarters.RowDataBound += new GridViewRowEventHandler(grdQuarters_RowDataBound);
    }
Example #47
0
    private int ImportCombination(int idProduct, string referenceCode, decimal basePrice, decimal priceBeforeImpact, decimal impactPrice, decimal PriceAfterImpact, decimal price, decimal impactWeight, decimal weight, int Quantity, int idColor, int idSize)
    {
        try
        {
            DataClassesDataContext db = new DataClassesDataContext();
            int            firstQty   = 0;
            Class_Employee emp        = new Class_Employee();
            var            employee   = emp.GetData_By_Token(HttpContext.Current.Request.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieAdmin"].ToString()].Value);

            if (db.TBProduct_Combinations.Where(x => !x.Deflag && x.ReferenceCode == referenceCode).FirstOrDefault() != null)
            {
                TBProduct_Combination data = db.TBProduct_Combinations.Where(x => !x.Deflag && x.ReferenceCode == referenceCode).FirstOrDefault();
                firstQty      = data.Quantity;
                data.Quantity = Quantity;
                db.SubmitChanges();
                return(data.IDProduct_Combination);
            }

            TBProduct_Combination _newData = new TBProduct_Combination();
            TBValue color = db.TBValues.Where(x => !x.Deflag && x.IDValue == idColor).FirstOrDefault();
            TBValue size  = db.TBValues.Where(x => !x.Deflag && x.IDValue == idSize).FirstOrDefault();
            _newData.IDProduct          = idProduct;
            _newData.ReferenceCode      = referenceCode;
            _newData.Name               = color.TBAttribute.Name + " : " + color.Name + ", " + size.TBAttribute.Name + " : " + size.Name;
            _newData.DateInsert         = DateTime.Now;
            _newData.DateLastUpdate     = DateTime.Now;
            _newData.BasePrice          = basePrice;
            _newData.PriceBeforeImpact  = priceBeforeImpact;
            _newData.PriceAfterImpact   = PriceAfterImpact;
            _newData.Price              = price;
            _newData.WeightBeforeImpact = weight;
            _newData.Weight             = weight;
            _newData.Quantity           = Quantity;
            _newData.DateLastUpdate     = DateTime.Now;
            _newData.DateInsert         = DateTime.Now;
            db.TBProduct_Combinations.InsertOnSubmit(_newData);
            db.SubmitChanges();

            //INSERT DETAIL COMBINATAION COLOR
            TBProduct_Combination_Detail _detail = new TBProduct_Combination_Detail();
            _detail.IDProduct_Combination = _newData.IDProduct_Combination;
            _detail.IDValue       = color.IDValue;
            _detail.NameAttribute = color.TBAttribute.Name;
            _detail.NameValue     = color.Name;
            _detail.DateInsert    = DateTime.Now;
            db.TBProduct_Combination_Details.InsertOnSubmit(_detail);

            //INSERT DETAIL COMBINATAION Size
            TBProduct_Combination_Detail _detailSize = new TBProduct_Combination_Detail();
            _detailSize.IDProduct_Combination = _newData.IDProduct_Combination;
            _detailSize.IDValue       = size.IDValue;
            _detailSize.NameAttribute = size.TBAttribute.Name;
            _detailSize.NameValue     = size.Name;
            _detailSize.DateInsert    = DateTime.Now;
            db.TBProduct_Combination_Details.InsertOnSubmit(_detailSize);
            db.SubmitChanges();

            //INSERT LOG
            Class_Log_Stock log = new Class_Log_Stock();
            log.Insert(employee.IDEmployee, _detail.TBProduct_Combination.IDProduct_Combination, _detail.TBProduct_Combination.Name, firstQty, Quantity, Quantity, "initial", "Import master product" + " by " + employee.Name + "( " + employee.Email + " )");

            return(_newData.IDProduct_Combination);
        }
        catch (Exception)
        {
            return(0);
        }
    }
Example #48
0
 /// <summary>
 /// 通用資料倉儲
 /// </summary>
 /// <param name="dataContext">資料實體</param>
 /// <returns>資料倉儲介面</returns>
 public static IAlert AlertRepository(DataClassesDataContext dataContext = null)
 {
     return(new AlertRepository(dataContext));
 }
    /// <summary>
    /// 搜索按钮事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void searchbotton_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            int      n    = sel.SelectedIndex;
            string[] type = { "Title", "Author", "Publisher", "ISBN", "Category" };

            DataClassesDataContext db = new DataClassesDataContext();
            var books = db.ExecuteQuery <Book>("select * from Book where " + type[n] + " like \'%" + inputtextbox.Text + "%\'");


            foreach (Book book in books)
            {
                TableRow row = new TableRow();
                row.CssClass = "s_item";

                TableCell cell = new TableCell();
                cell.CssClass = "tdstyle";

                ImageButton img = new ImageButton();
                img.ImageUrl    = book.CoverImagePath.ToString();
                img.Width       = 150;
                img.PostBackUrl = "~/BookWareHouse/CheckBook.aspx?BookID=" + book.BookID.ToString();

                cell.Controls.Add(img);
                cell.HorizontalAlign = HorizontalAlign.Right;
                row.Cells.Add(cell);


                TableCell cell2 = new TableCell();
                cell2.CssClass        = "td_pad";
                cell2.HorizontalAlign = HorizontalAlign.Left;
                Table celltable = new Table();
                celltable.CssClass        = "tbstyle";
                celltable.HorizontalAlign = HorizontalAlign.Left;

                TableRow  rightrow1  = new TableRow();
                TableCell rightcell1 = new TableCell();
                rightcell1.CssClass        = "td_row";
                rightcell1.HorizontalAlign = HorizontalAlign.Left;

                HyperLink link = new HyperLink();
                link.NavigateUrl = "~/BookWareHouse/CheckBook.aspx?BookID=" + book.BookID.ToString();
                link.Text        = book.Title.ToString();
                link.Font.Size   = 18;
                link.CssClass    = "h4";

                rightcell1.Controls.Add(link);
                rightrow1.Cells.Add(rightcell1);
                celltable.Rows.Add(rightrow1);

                TableRow  rightrow2  = new TableRow();
                TableCell rightcell2 = new TableCell();
                rightcell2.CssClass = "td_row";
                rightcell2.Text     = book.Author + "/" + book.Publisher + "/" + book.ISBN;

                rightrow2.Cells.Add(rightcell2);
                celltable.Rows.Add(rightrow2);

                TableRow  rightrow3  = new TableRow();
                TableCell rightcell3 = new TableCell();
                rightcell3.CssClass = "td_row";
                rightcell3.Text     = "类型:" + book.Category;

                rightrow3.Cells.Add(rightcell3);
                celltable.Rows.Add(rightrow3);

                TableRow  rightrow4  = new TableRow();
                TableCell rightcell4 = new TableCell();
                rightcell4.CssClass = "td_row";
                rightcell4.Text     = "评分:" + book.Score.ToString();

                rightrow4.Cells.Add(rightcell4);
                celltable.Rows.Add(rightrow4);

                cell2.Controls.Add(celltable);
                row.Cells.Add(cell2);
                Table1.Rows.Add(row);
            }
        }
    }
Example #50
0
        private void btnCommit_Click(object sender, EventArgs e)
        {
            using (var Content = new DataClassesDataContext())
            {
                if (dtpGameDate.Value == GetLastUploadGameDate())
                {
                    MessageBox.Show("An upload for this game date has already occured", "Cannot Proceed",
                                    MessageBoxButtons.OK);

                    return;
                }
                //create a new upload
                var newUpload = new Upload();
                newUpload.GameDate   = dtpGameDate.Value;
                newUpload.UploadDate = DateTime.Now.Date;
                newUpload.SeasonID   = _SeasonID;
                Content.Uploads.InsertOnSubmit(newUpload);
                Content.SubmitChanges();

                foreach (var teamModel in Teams)
                {
                    //Update or create record
                    var record =
                        Content.Records.FirstOrDefault(x => x.TeamID == teamModel.TeamID && x.SeasonID == _SeasonID);
                    if (record == null)
                    {
                        record              = new Record();
                        record.TeamID       = teamModel.TeamID;
                        record.SeasonID     = _SeasonID;
                        record.Wins         = teamModel.Wins;
                        record.Losses       = teamModel.Losses;
                        record.PythWins     = teamModel.PythWins;
                        record.PythLosses   = teamModel.PythLosses;
                        record.DateModified = DateTime.Now.Date;
                        Content.Records.InsertOnSubmit(record);
                        Content.SubmitChanges();
                    }
                    else
                    {
                        record.Wins         = teamModel.Wins;
                        record.Losses       = teamModel.Losses;
                        record.PythWins     = teamModel.PythWins;
                        record.PythLosses   = teamModel.PythLosses;
                        record.DateModified = DateTime.Now.Date;
                        Content.SubmitChanges();
                    }

                    //Update or create opponentrecords
                    foreach (var opponentModel in teamModel.OpponentsList)
                    {
                        if (opponentModel.WinsVersus != 0 || opponentModel.LossesVersus != 0)
                        {
                            var opponentRecord = Content.OpponentsRecords.FirstOrDefault(
                                x => x.TeamID == teamModel.TeamID && x.OpponentTeamID == opponentModel.OpponentTeamID &&
                                x.SeasonID == _SeasonID);

                            if (opponentRecord == null)
                            {
                                opponentRecord                = new OpponentsRecord();
                                opponentRecord.SeasonID       = _SeasonID;
                                opponentRecord.TeamID         = teamModel.TeamID;
                                opponentRecord.OpponentTeamID = opponentModel.OpponentTeamID;
                                opponentRecord.WinsAgainst    = opponentModel.WinsVersus;
                                opponentRecord.LossesAgainst  = opponentModel.LossesVersus;
                                opponentRecord.DateModified   = DateTime.Now.Date;
                                Content.OpponentsRecords.InsertOnSubmit(opponentRecord);
                                Content.SubmitChanges();
                            }
                            else
                            {
                                opponentRecord.WinsAgainst   = opponentModel.WinsVersus;
                                opponentRecord.LossesAgainst = opponentModel.LossesVersus;
                                opponentRecord.DateModified  = DateTime.Now.Date;
                                Content.SubmitChanges();
                            }
                        }
                    }

                    //Insert team calculations - new for each upload
                    var calculations = new TeamCalculation();
                    calculations.UploadID    = newUpload.UploadID;
                    calculations.SeasonID    = _SeasonID;
                    calculations.TeamID      = teamModel.TeamID;
                    calculations.WP          = teamModel.WinningPercentage;
                    calculations.OWP         = teamModel.OpponentsWinPercentage;
                    calculations.OOWP        = teamModel.OpponentsOpponentWinPercentage;
                    calculations.SoS         = teamModel.StrengthOfSchedule;
                    calculations.RPI         = teamModel.RPI;
                    calculations.PythOOWP    = teamModel.PythOpponentsOpponentWinPercentage;
                    calculations.PythOWP     = teamModel.PythOpponentsWinPercentage;
                    calculations.PythRPI     = teamModel.PythRPI;
                    calculations.PythWP      = teamModel.PythWinPercentage;
                    calculations.DateCreated = DateTime.Now.Date;
                    Content.TeamCalculations.InsertOnSubmit(calculations);
                    Content.SubmitChanges();
                }
            }
            this.Close();
        }
Example #51
0
    protected void ImageButtonChangePassword_Click(object sender, ImageClickEventArgs e)
    {
        lblsuccess.Visible = false;
        try
        {
            if (Session["UserId"] != null)
            {
                int userId = Convert.ToInt32(Session["UserId"]);

                DataClassesDataContext db = new DataClassesDataContext();
                if (TextBoxOld.Text != "" && TextBoxNew.Text != "" && TextBoxNew2.Text != "")
                {
                    Literal1.Text = "";

                    var    query     = db.Users.Where(u => u.UserId == userId).SingleOrDefault();
                    string OldPass   = TextBoxOld.Text;
                    string NewPass   = TextBoxNew.Text;
                    string RpNewPass = TextBoxNew2.Text;

                    MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();

                    Byte[] hashedBytesOld;
                    Byte[] hashedBytes;

                    UTF8Encoding encoder = new UTF8Encoding();

                    hashedBytes    = md5Hasher.ComputeHash(encoder.GetBytes(NewPass));
                    hashedBytesOld = md5Hasher.ComputeHash(encoder.GetBytes(OldPass));

                    if (hashedBytesOld == query.Password)
                    {
                        lblerror.Visible = false;

                        if (NewPass == RpNewPass)
                        {
                            query.Password = hashedBytes;
                            db.SubmitChanges();
                            lblsuccess.Visible = true;
                        }
                    }
                    else
                    {
                        lblerror.Visible = true;
                    }
                }
                else
                {
                    Response.Redirect("Login.aspx");
                }
            }
            else
            {
                if (TextBoxOld.Text == "")
                {
                    Literal1.Text = "<p class='FormValidation'>کلمه عبور خود را  وارد نمایید!</p>";
                }
                else if (TextBoxNew.Text == "" && TextBoxNew2.Text == "")
                {
                    Literal1.Text = "<p class='FormValidation'>کلمه عبور جدید و تکرار آن را  وارد نمایید!</p>";
                }
            }
        }
        catch (Exception)
        {
            Response.Redirect("~/Default.aspx");
        }
    }
Example #52
0
 /// <summary>
 /// 通用資料倉儲
 /// </summary>
 /// <param name="dataContext">資料實體</param>
 /// <returns>資料倉儲介面</returns>
 public static IWeather WeatherRepository(DataClassesDataContext dataContext = null)
 {
     return(new WeatherRepository(dataContext));
 }
Example #53
0
 /// <summary>
 /// 通用資料倉儲
 /// </summary>
 /// <param name="dataContext">資料實體</param>
 /// <returns>資料倉儲介面</returns>
 public static ITraLine TraRepository(DataClassesDataContext dataContext = null)
 {
     return(new TraRepository(dataContext));
 }
Example #54
0
 /// <summary>
 /// 通用資料倉儲
 /// </summary>
 /// <param name="dataContext">資料實體</param>
 /// <returns>資料倉儲介面</returns>
 public static IParking ParkingRepository(DataClassesDataContext dataContext = null)
 {
     return(new ParkingRepository(dataContext));
 }
Example #55
0
 /// <summary>
 /// 通用資料倉儲
 /// </summary>
 /// <param name="dataContext">資料實體</param>
 /// <returns>資料倉儲介面</returns>
 public static IBusDynamic BusDynamicRepository(DataClassesDataContext dataContext = null)
 {
     return(new BusDynamicRepository(dataContext));
 }
Example #56
0
        public static void CreateFileForPeriodAndBank(int bankID, DateTime startDate, DateTime endDate)
        {
            DataClassesDataContext dcdc = new DataClassesDataContext();
            DateTime dt1 = startDate;
            DateTime dt2 = endDate;
            int      d1  = dt1.Day;
            int      m1  = dt1.Month;
            int      y1  = dt1.Year;
            int      d2  = dt2.Day;
            int      m2  = dt2.Month;
            int      y2  = dt2.Year;

            PDFCreators pdf = new PDFCreators(false, 25, 25, 25, 25);

            pdf.OpenPDF();
            pdf.SetTitle("  ");
            pdf.SetTitle("  ");

            pdf.SetTitle("Слипови во период  " + startDate.ToShortDateString() + " - " + endDate.ToShortDateString());

            List <Slip> slipList = Slip.GetForPeriodAndBank(startDate, endDate, bankID);

            slipList = slipList.OrderBy(c => c.Date).ThenBy(c => c.SlipNumber).ToList();
            decimal totalValue      = 0;
            decimal partialValue    = 0;
            decimal dayTotalValue   = 0;
            decimal dayPartialValue = 0;
            int     orderNumber     = 0;
            bool    differentDays   = false;

            // int dayOrderNumber = 0;
            // int monthOrderNumber = 0;
            string[]   headersP            = { "РБ", "Број на слип", "Број на полиса", "Вредност", "Провизија", "Вредност без провизија", "Дата" };
            float[]    policyColumnsWidths = { 5, 20, 20, 15, 10, 15, 15 };
            TypeCode[] codes = { TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.Decimal, TypeCode.Decimal, TypeCode.Decimal, TypeCode.DateTime };
            pdf.CreateTable(7, false, headersP, "", policyColumnsWidths);
            DateTime currentDate;

            if (slipList.Count > 0)
            {
                currentDate = slipList[0].Date;
            }
            else
            {
                currentDate = DateTime.Today;
            }
            foreach (Slip s in slipList)
            {
                if (s.Date != currentDate)
                {
                    differentDays = true;
                    object[] vals = new object[7];
                    vals[0] = "";
                    vals[1] = "Вкупно";
                    vals[2] = "";
                    vals[3] = String.Format("{0:#,0.00}", dayTotalValue);
                    vals[4] = "";
                    vals[5] = String.Format("{0:#,0.00}", dayPartialValue);
                    vals[6] = "";
                    pdf.AddDataRow1(vals, 7, codes);
                    dayPartialValue = 0;
                    dayTotalValue   = 0;
                    currentDate     = s.Date;
                    orderNumber     = 0;
                    totalValue     += s.TotalValue;
                    partialValue   += s.PartialValue;
                }
                else
                {
                    orderNumber++;
                    object[] vals2 = new object[7];
                    vals2[0] = orderNumber;
                    vals2[1] = s.SlipNumber;
                    vals2[2] = s.PolicyNumber;
                    vals2[3] = String.Format("{0:#,0.00}", s.TotalValue);
                    vals2[4] = String.Format("{0:#,0.00}", s.ProvisionRate.Provision);
                    vals2[5] = String.Format("{0:#,0.00}", s.PartialValue);
                    vals2[6] = s.Date.ToShortDateString();
                    pdf.AddDataRow1(vals2, 7, codes);
                    totalValue      += s.TotalValue;
                    partialValue    += s.PartialValue;
                    dayTotalValue   += s.TotalValue;
                    dayPartialValue += s.PartialValue;
                }
            }
            //if (differentDays) {
            //    object[] vals5 = new object[7];
            //    vals5[0] = "";
            //    vals5[1] = "Вкупно";
            //    vals5[2] = "";
            //    vals5[3] = String.Format("{0:#,0.00}", dayTotalValue);
            //    vals5[4] = "";
            //    vals5[5] = String.Format("{0:#,0.00}", dayPartialValue);
            //    vals5[6] = "";
            //    pdf.AddDataRow1(vals5, 7, codes);

            //}

            object[] vals1 = new object[7];
            vals1[0] = "";
            vals1[1] = "Вкупно";
            vals1[2] = "";
            vals1[3] = String.Format("{0:#,0.00}", totalValue);
            vals1[4] = "";
            vals1[5] = String.Format("{0:#,0.00}", partialValue);
            vals1[6] = "";
            pdf.AddDataRow1(vals1, 7, codes);

            pdf.AddTable();
            pdf.FinishPDF();
        }
Example #57
0
        //修改
        public void Modify_Click(object sender, RoutedEventArgs e)
        {
            //仅当教师用户登录可用
            //判断Frame中的Page页面
            var control = Selection.arg;  //从Selection获取参数,判断表

            if (control == "fromInfo")
            {
                Add_StudentInfo        asi = new Add_StudentInfo();
                DataClassesDataContext db  = new DataClassesDataContext();
                var query = from n in db.学生信息表
                            //where n.学号 == StudentInfo.arg
                            where n.学号 == num
                            select n;
                foreach (var m in query)
                {
                    asi.xuehao.Text   = m.学号;
                    asi.zhuanye.Text  = m.专业;
                    asi.zhenghi.Text  = m.政治面貌;
                    asi.xingming.Text = m.姓名;
                    asi.xingbie.Text  = m.性别;
                    asi.jiating.Text  = m.家庭住址;
                    asi.lianxi.Text   = m.联系电话;
                    asi.birthday.Text = m.出生年月;
                    asi.banji.Text    = m.班级;
                    asi.jiguan.Text   = m.籍贯;
                }
                this.Frame.Content = asi;
            }
            else if (control == "fromAch")
            {
                // Add_StudentInfo asi = new Add_StudentInfo();
                Add_StudentAchievement asa = new Add_StudentAchievement();
                DataClassesDataContext db  = new DataClassesDataContext();
                var query = from n in db.学生成绩表
                            //where n.学号 == StudentInfo.arg
                            where n.学号 == num
                            select n;
                foreach (var m in query)
                {
                    asa.xuehao.Text   = m.学号;
                    asa.zhuanye.Text  = m.专业;
                    asa.xingming.Text = m.姓名;
                    asa.banji.Text    = m.班级;
                    asa.fenshu1.Text  = m.高等数学_上_;
                    asa.fenshu2.Text  = m.高等数学_下_;
                    asa.fenshu3.Text  = m.概率论;
                    asa.fenshu4.Text  = m.线性代数;
                    asa.fenshu5.Text  = m.c语言程序设计;
                    asa.fenshu6.Text  = m.离散数学;
                }
                this.Frame.Content = asa;
            }
            else if (control == "fromFile")
            {
                // Add_StudentInfo asi = new Add_StudentInfo();
                //  Add_StudentAchievement asa = new Add_StudentAchievement();
                Add_StudentFile asf = new Add_StudentFile();

                DataClassesDataContext db = new DataClassesDataContext();
                var query = from n in db.学生档案表
                            //where n.学号 == StudentInfo.arg
                            where n.学号 == num
                            select n;
                foreach (var m in query)
                {
                    asf.xuehao.Text     = m.学号;
                    asf.zhuanye.Text    = m.专业;
                    asf.minzu.Text      = m.民族;
                    asf.xingming.Text   = m.姓名;
                    asf.xingbie.Text    = m.性别;
                    asf.jiating.Text    = m.家庭住址;
                    asf.lianxi.Text     = m.联系电话;
                    asf.jiangcheng.Text = m.奖罚情况;
                    asf.banji.Text      = m.班级;
                    asf.jiguan.Text     = m.籍贯;
                    asf.liuji.Text      = m.留级情况;
                }
                this.Frame.Content = asf;
            }
        }
Example #58
0
 internal static bool HasUser(int user_id, int parkplan_id)
 {
     using (var db = new DataClassesDataContext()) {
         return(db.users_has_parkplans.Any(uhp => uhp.parkplans_id == parkplan_id && uhp.users_id == user_id));
     }
 }
 public static DataClassesDataContext getConnection()
 {
     datacontext = new DataClassesDataContext(_thisConnectionString);
     return(datacontext);
 }
Example #60
0
    public int FindPagingCount(int startIndex, int pageSize, string sortColumn)
    {
        var c = new DataClassesDataContext();

        return(c.employees.Count());
    }