public JsonResult SaveChanges(string Name, string Sectors, string Terms)
        {
            _listUsers.Read();

            List <int> ListSectorsID = Sectors.Split(',').ToList().Select(s => int.Parse(s)).ToList();

            User usr = _listUsers.Where(u => u.Name == Name).FirstOrDefault();

            if (usr == null)
            {
                usr      = new User();
                usr.Name = Name;
                usr.Save();
                usr.GetID();

                UserInfos userInfo = new UserInfos();
                userInfo.Terms  = Terms.Equals("true");
                userInfo.UserID = usr.UserID;
                userInfo.Insert();
            }

            foreach (int sector in ListSectorsID)
            {
                _listUserSectors.Add(new UserSectors
                {
                    UserID   = usr.UserID,
                    SectorID = sector
                });
            }
            _listUserSectors.Save();

            return(Json(ListSectorsID));
        }
        protected void btnAddNeverFollow_Click(object sender, EventArgs e)
        {
            List <Twitter.User> addToNeverFollowList = new List <Twitter.User>();

            foreach (GridViewRow row in gvUsers.Rows)
            {
                Control ctrl = row.FindControl("cbxDelete");
                if (ctrl != null)
                {
                    CheckBox cbx = (CheckBox)ctrl;
                    if (cbx.Checked)
                    {
                        Control lblctrl = row.FindControl("lblUserId");
                        if (lblctrl != null)
                        {
                            Label lbl  = (Label)lblctrl;
                            var   user = ListUsers.Where(k => k.UserId == lbl.Text).FirstOrDefault();
                            addToNeverFollowList.Add(user);
                            ListUsers.Remove(user);
                        }
                    }
                }
            }
            CreateDestroyList.AddToNeverFollowList(addToNeverFollowList);
            Serializer.WriteFollowersXML(ListUsers.ToList(), Constants.FriendsFollowers.Users.ToString());
            BindData();
        }
        protected void btnDestroy_Click(object sender, EventArgs e)
        {
            if (ListUsers.Count > 0)
            {
                bool usersChanged     = false;
                bool followersChanged = false;

                TwitterAuthenticate();
                try {
                    foreach (GridViewRow row in gvUsers.Rows)
                    {
                        Control ctrl = row.FindControl("cbxDelete");
                        if (ctrl != null)
                        {
                            CheckBox cbx = (CheckBox)ctrl;
                            if (cbx.Checked)
                            {
                                Control lblctrl = row.FindControl("lblUserId");
                                if (lblctrl != null)
                                {
                                    Label lbl  = (Label)lblctrl;
                                    var   user = ListUsers.Where(k => k.UserId == lbl.Text).FirstOrDefault();
                                    if (user != null)
                                    {
                                        twdata = new Twitter(user, Twitter.TwitterType.Unfollow);
                                        Twitter.User utoremove = ListFriends.Find(x => x.UserId == user.UserId);
                                        if (utoremove != null && ListFriends.Contains(utoremove))
                                        {
                                            ListFriends.Remove(utoremove);
                                            followersChanged = true;
                                        }
                                        ListUsers.Remove(user);
                                        usersChanged = true;
                                    }
                                }
                            }
                        }
                    }
                    if (followersChanged)
                    {
                        Serializer.WriteFollowersXML(ListFriends.ToList(), Constants.FriendsFollowers.Friends.ToString());
                    }
                    if (usersChanged)
                    {
                        Serializer.WriteFollowersXML(ListUsers.ToList(), Constants.FriendsFollowers.Analyze.ToString());
                        Serializer.WriteFollowersXML(ListUsers.ToList(), Constants.FriendsFollowers.Unfollow.ToString());
                        Serializer.WriteFollowersXML(ListUsers.ToList(), Constants.FriendsFollowers.Users.ToString());
                    }
                    BindData();
                } catch (WebException wex) {
                    BindData();
                    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", string.Format("alert('{0}');", "No internet connection: " + wex.Message.Replace("'", string.Empty)), true);
                } catch (Exception ex) {
                    //do nothing
                }
            }
        }
示例#4
0
        private void DeleteUserMethod()
        {
            string login = SelectedUser.login;

            if (Users.DeleteUser(login))
            {
                var msg = Utils.Utils.createMessageBox("L'utilisateur " + login + " a été supprimé avec succès !");
                msg.Show();
                ListUsers.Remove(ListUsers.Where(i => i.login == login).Single());
                SelectedUser = ListUsers.First();
            }
            else
            {
                MaterialMessageBox.ShowError("L'utilisateur " + login + " n'a pas put être supprimé Réessayez plus tard !");
            }
        }
示例#5
0
        /// <summary>
        /// 导出审批表word
        /// </summary>
        /// <param name="path">文件路径</param>
        /// <param name="Type">0-首营供货商,1-首营客户,2-首营药品</param>
        /// <returns></returns>
        public bool CreateWord(string Filename, string Name, int Type)
        {
            Word._Application oWord = new Word.Application();
            Word._Document    oDoc  = null;
            try
            {
                object oMissing = System.Reflection.Missing.Value;

                oWord.Visible = false;
                object oTemplate = Filename;
                oDoc = oWord.Documents.Open(ref oTemplate, ref oMissing, ref oMissing, ref oMissing);
                oDoc.Activate();

                #region 这是首营信息们
                if (b != null)
                {
                    this.insertMarks(oDoc, 0);
                    this.insertGsp(oDoc, b.GSPLCID, b.id);
                    this.insertMedicineBussiness(oDoc, b.MedicineBusinessLCID);
                    this.insertBussiness(oDoc, b.BusinessLCID);
                    this.insertOrg(oDoc, b.OrganizationCodeLCID);
                    this.insertTax(oDoc, b.TaxRegisterLCID);
                    this.insertInstB(oDoc, b.InstrumentsBusinessLCID);
                    this.insertInstP(oDoc, b.InstrumentsProductionLCID);
                    this.insertHealth(oDoc, b.HealthLCID);
                    this.InsertGMP(oDoc, b.GMPLCID);
                    this.insertDelegate(oDoc);
                    this.insertSCXKZ(oDoc, b.MedicineProductionLCID);
                    this.insertQualityAgreement(oDoc);
                    this.insertBank(oDoc);

                    Service.Models.QueryApprovalFlowRecordModel aq = new  Service.Models.QueryApprovalFlowRecordModel
                    {
                        FlowId = b.ApprovalFlowId
                    };

                    var c = baseform.PharmacyDatabaseService.SearchApprovalFlowRecordsByQueryModel(out msg, aq).OrderBy(r => r.ApproveTime).ToList();

                    if (oDoc.Bookmarks["flow1"] != null)
                    {
                        for (int i = 0; i < c.Count; i++)
                        {
                            oDoc.Bookmarks["flow" + (i + 1)].Select();
                            oDoc.Bookmarks["flow" + (i + 1)].Range.Text = c[i].Comment;
                            var o = ListUsers.Where(r => r.Id == c[i].ApproveUserId).FirstOrDefault();
                            oDoc.Bookmarks["flowuser" + (i + 1)].Range.Text = o.Employee.Name + "  " + c[i].ApproveTime.ToLongDateString();
                        }
                    }
                }

                if (p != null)
                {
                    this.insertPurchaseBasicInfo(oDoc);
                    this.insertGsp(oDoc, p.GSPLCID, p.Id);
                    this.insertMedicineBussiness(oDoc, p.MedicineBusinessLCID);
                    this.insertBussiness(oDoc, p.BusinessLCID);
                    this.insertOrg(oDoc, p.OrganizationCodeLCID);
                    this.insertTax(oDoc, p.TaxRegisterLCID);
                    this.insertInstB(oDoc, p.InstrumentsBusinessLCID);
                    this.insertInstP(oDoc, p.InstrumentsProductionLCID);
                    this.insertHealth(oDoc, p.HealthLCID);
                    this.InsertGMP(oDoc, p.GMPLCID);
                    this.insertLn(oDoc, p.LnstitutionLegalPersonLCID);
                    this.InsertMMInst(oDoc, p.MmedicalInstitutionLCID);
                    this.insertDelegate(oDoc);
                    this.insertQualityAgreement(oDoc);
                }

                if (d != null)
                {
                    this.InsertDrugInfo(oDoc);
                }

                #region 医疗器械信息
                if (Inst != null)
                {
                    oDoc.Bookmarks["T1"].Select();
                    oDoc.Bookmarks["T1"].Range.Text = BugsBox.Pharmacy.AppClient.Common.PharmacyClientConfig.Config.Store.Name;

                    oDoc.Bookmarks["D1"].Range.Text  = Inst.ProductGeneralName;
                    oDoc.Bookmarks["D2"].Range.Text  = Inst.LicensePermissionNumber;
                    oDoc.Bookmarks["D3"].Range.Text  = Inst.PerformanceStandards;
                    oDoc.Bookmarks["D4"].Range.Text  = Inst.StandardCode;
                    oDoc.Bookmarks["D5"].Range.Text  = Inst.Code;
                    oDoc.Bookmarks["D6"].Range.Text  = Inst.DocCode;
                    oDoc.Bookmarks["D7"].Range.Text  = Inst.Pinyin;
                    oDoc.Bookmarks["D8"].Range.Text  = Inst.BarCode;
                    oDoc.Bookmarks["D11"].Range.Text = Inst.DictionaryMeasurementUnitCode;
                    oDoc.Bookmarks["D12"].Range.Text = Inst.DictionaryDosageCode;
                    oDoc.Bookmarks["D13"].Range.Text = Inst.DictionarySpecificationCode;
                    oDoc.Bookmarks["D14"].Range.Text = Inst.FactoryName;
                    oDoc.Bookmarks["D15"].Range.Text = Inst.Contact;
                    oDoc.Bookmarks["D16"].Range.Text = Inst.BusinessScopeCode;
                    oDoc.Bookmarks["D17"].Range.Text = Inst.IsApproval;
                    oDoc.Bookmarks["D18"].Range.Text = Inst.Valid;
                    oDoc.Bookmarks["D19"].Range.Text = Inst.WareHouses;
                    oDoc.Bookmarks["D20"].Range.Text = Inst.WareHouseZone;
                    oDoc.Bookmarks["D21"].Range.Text = Inst.DrugStorageTypeCode;
                    oDoc.Bookmarks["D22"].Range.Text = Inst.MaxInventoryCount.ToString();
                    oDoc.Bookmarks["D23"].Range.Text = Inst.MinInventoryCount.ToString();
                    oDoc.Bookmarks["D24"].Range.Text = Inst.ValidPeriod.ToString() + "个月";
                    oDoc.Bookmarks["D25"].Range.Text = Inst.DrugCategoryCode;
                    oDoc.Bookmarks["D26"].Range.Text = Inst.Price.ToString();
                    oDoc.Bookmarks["D27"].Range.Text = Inst.SalePrice.ToString();
                    oDoc.Bookmarks["D28"].Range.Text = Inst.LimitedUpPrice.ToString();
                    oDoc.Bookmarks["D29"].Range.Text = Inst.LimitedLowPrice.ToString();
                    oDoc.Bookmarks["D31"].Range.Text = Inst.Description;
                    oDoc.Bookmarks["D48"].Range.Text = Inst.CreateTime.ToString();
                    oDoc.Bookmarks["D49"].Range.Text = Inst.CreateUserName;
                }
                #endregion

                #region 保健食品信息
                if (this.Food != null)
                {
                    oDoc.Bookmarks["T1"].Select();
                    oDoc.Bookmarks["T1"].Range.Text = BugsBox.Pharmacy.AppClient.Common.PharmacyClientConfig.Config.Store.Name;

                    oDoc.Bookmarks["D1"].Range.Text  = Food.ProductGeneralName;
                    oDoc.Bookmarks["D2"].Range.Text  = Food.LicensePermissionNumber;
                    oDoc.Bookmarks["D3"].Range.Text  = Food.PerformanceStandards;
                    oDoc.Bookmarks["D4"].Range.Text  = Food.LicensePermissionOutValidDate.ToShortDateString();
                    oDoc.Bookmarks["D5"].Range.Text  = Food.Code;
                    oDoc.Bookmarks["D6"].Range.Text  = Food.DocCode;
                    oDoc.Bookmarks["D7"].Range.Text  = Food.Pinyin;
                    oDoc.Bookmarks["D8"].Range.Text  = Food.BarCode;
                    oDoc.Bookmarks["D11"].Range.Text = Food.DictionaryMeasurementUnitCode;
                    oDoc.Bookmarks["D12"].Range.Text = Food.DictionaryDosageCode;
                    oDoc.Bookmarks["D13"].Range.Text = Food.DictionarySpecificationCode;
                    oDoc.Bookmarks["D14"].Range.Text = Food.FactoryName;
                    oDoc.Bookmarks["D15"].Range.Text = Food.Contact;
                    oDoc.Bookmarks["D16"].Range.Text = Food.BusinessScopeCode;
                    oDoc.Bookmarks["D17"].Range.Text = Food.IsApproval;
                    oDoc.Bookmarks["D18"].Range.Text = Food.Valid;
                    oDoc.Bookmarks["D19"].Range.Text = Food.WareHouses;
                    oDoc.Bookmarks["D20"].Range.Text = Food.WareHouseZone;
                    oDoc.Bookmarks["D21"].Range.Text = Food.DrugStorageTypeCode;
                    oDoc.Bookmarks["D22"].Range.Text = Food.MaxInventoryCount.ToString();
                    oDoc.Bookmarks["D23"].Range.Text = Food.MinInventoryCount.ToString();
                    oDoc.Bookmarks["D24"].Range.Text = Food.ValidPeriod.ToString() + "个月";
                    oDoc.Bookmarks["D25"].Range.Text = Food.IsImport;



                    oDoc.Bookmarks["D26"].Range.Text = Food.Price.ToString();
                    oDoc.Bookmarks["D27"].Range.Text = Food.SalePrice.ToString();
                    oDoc.Bookmarks["D28"].Range.Text = Food.LimitedUpPrice.ToString();
                    oDoc.Bookmarks["D29"].Range.Text = Food.LimitedLowPrice.ToString();

                    oDoc.Bookmarks["D30"].Range.Text = Food.Origin;
                    oDoc.Bookmarks["D31"].Range.Text = Food.Description;

                    oDoc.Bookmarks["D48"].Range.Text = Food.CreateTime.ToString();
                    oDoc.Bookmarks["D49"].Range.Text = Food.CreateUserName;
                }

                #endregion

                #endregion

                #region word保存
                System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
                sfd.Filter     = "Word Document(*.doc)|*.doc";
                sfd.DefaultExt = "Word Document(*.doc)|*.doc";
                sfd.FileName   = Name + DateTime.Now.Ticks + ".doc";
                if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    object filename = sfd.FileName;
                    oDoc.SaveAs(ref filename, ref oMissing, ref oMissing, ref oMissing,
                                ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                ref oMissing, ref oMissing);
                    oDoc.Close(ref oMissing, ref oMissing, ref oMissing);
                    if (oDoc != null)
                    {
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(oDoc);
                        oDoc = null;
                    }
                    if (oWord != null)
                    {
                        oWord.Quit();
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(oWord);
                        oWord = null;
                    }
                    return(true);
                }
                else
                {
                    if (oDoc != null)
                    {
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(oDoc);
                        oDoc = null;
                    }
                    if (oWord != null)
                    {
                        oWord.Quit(Word.WdSaveOptions.wdDoNotSaveChanges);
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(oWord);
                        oWord = null;
                    }
                    return(false);
                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(Name + ":审批信息表导出失败!");
                if (oWord != null)
                {
                    oWord.Quit(Word.WdSaveOptions.wdDoNotSaveChanges);
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oWord);
                    oWord = null;
                }
                if (oDoc != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oDoc);
                    oDoc = null;
                }
                return(false);
            }
            finally
            {
                if (oWord != null)
                {
                    oWord.Quit();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oWord);
                    oWord = null;
                }
                if (oDoc != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oDoc);
                    oDoc = null;
                }
            }
            #endregion
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            if (ListUsers.Count > 0)
            {
                bool usersChanged     = false;
                bool friendsChanged   = false;
                bool followersChanged = false;

                foreach (GridViewRow row in gvUsers.Rows)
                {
                    Control ctrl = row.FindControl("cbxDelete");
                    if (ctrl != null)
                    {
                        CheckBox cbx = (CheckBox)ctrl;
                        if (cbx.Checked)
                        {
                            Control lblctrl = row.FindControl("lblUserId");
                            if (lblctrl != null)
                            {
                                Label lbl  = (Label)lblctrl;
                                var   user = ListUsers.Where(k => k.UserId == lbl.Text).FirstOrDefault();
                                if (user != null)
                                {
                                    var uremove = ListFriends.Where(x => x.UserId == user.UserId).FirstOrDefault();
                                    if (uremove != null)
                                    {
                                        ListFriends.Remove(uremove);
                                        friendsChanged = true;
                                    }
                                    var furemove = ListFollowers.Where(x => x.UserId == user.UserId).FirstOrDefault();
                                    if (furemove != null)
                                    {
                                        ListFollowers.Remove(furemove);
                                        followersChanged = true;
                                    }
                                    ListUsers.Remove(user);
                                    usersChanged = true;
                                }
                            }
                        }
                    }
                }
                if (friendsChanged)
                {
                    Serializer.WriteFollowersXML(ListFriends.ToList(), Constants.FriendsFollowers.Friends.ToString());
                }
                if (followersChanged)
                {
                    Serializer.WriteFollowersXML(ListFollowers.ToList(), Constants.FriendsFollowers.Followers.ToString());
                }
                if (usersChanged)
                {
                    if (friendsChanged)
                    {
                        Serializer.WriteFollowersXML(ListUsers.ToList(), Constants.FriendsFollowers.Analyze.ToString());
                    }
                    if (friendsChanged)
                    {
                        Serializer.WriteFollowersXML(ListUsers.ToList(), Constants.FriendsFollowers.Unfollow.ToString());
                    }
                    if (followersChanged)
                    {
                        Serializer.WriteFollowersXML(ListUsers.ToList(), Constants.FriendsFollowers.NotFollowing.ToString());
                    }
                    Serializer.WriteFollowersXML(ListUsers.ToList(), Constants.FriendsFollowers.Users.ToString());
                }
                BindData();
            }
        }
示例#7
0
        //este método  es para poder verlo en una página razor por tanto me hace falta trabajar con los model

        public async Task <List <InputModelRegistrar> > GetUsuariosAsync(String valor)
        {
            int id = 0;
            List <ApplicationUser> Users;

            Users = _context.Users.ToList();
            string imagen = "default.png";
            //lista de la tabla AspNetUsers
            List <ApplicationUser>            ListUsers;
            IEnumerable <InputModelRegistrar> imageUsers;
            string rootFolder   = Directory.GetCurrentDirectory();
            string imageDefault = "default.png";

            //lista de la tabla Usuarios
            List <Usuarios> ListUsuarios;

            ListUsuarios = _context.Usuarios.ToList();
            if (valor != null)
            {
                //Listar los usuarios de la tabla AspNetUsers
                ListUsers = Users.Where(u => u.Email.StartsWith(valor) || u.UserName.StartsWith(valor) ||
                                        u.PhoneNumber.StartsWith(valor)).ToList();
                //relacionar el email con el Id
                var user    = ListUsers.First();
                var usuario = ListUsuarios.Where(u => u.ApplicationUserId == user.Id);
                //parts.Find(x => x.PartName.Contains("seat")));
                //coger el ID del usuario para añadir los datos de ese usuario en donde corresponde
            }
            else
            {
                ListUsers    = _context.Users.ToList();
                ListUsuarios = _context.Usuarios.ToList();
            }
            //viendo como lo voy a hacer la programación

            //lista de usuarios además utilizando datos de la otra tabla
            //userList es la tabla de usuarios Users
            List <InputModelRegistrar> userList = new List <InputModelRegistrar>();
            List <InputModelRegistrar> listUser = new List <InputModelRegistrar>();


            var users =
                from ListUsers0 in ListUsers
                join ListUsuarios0 in ListUsuarios on ListUsers0.Id equals ListUsuarios0.ApplicationUserId
                select ListUsuarios0;
            //Usuarios de AspnetUsers
            var usersA =
                from ListUsers0 in ListUsers
                join ListUsuarios0 in ListUsuarios on ListUsers0.Id equals ListUsuarios0.ApplicationUserId
                select ListUsers0;

            var users0 =
                //AU es AspnetUsers
                from AU in ListUsers
                from Usuarios in ListUsuarios
                where Usuarios.ApplicationUserId != AU.Id
                select AU;

            //Usuarios que no esta relacionado con la tabla Usuarios
            foreach (var item in users0)
            {
                var role = _usersRole.GetRole(_userManager, _roleManager, item.Id);

                userList.Add(new InputModelRegistrar
                {
                    Email  = item.Email,
                    Imagen = Path.Combine(rootFolder + "wwwroot\\images\\fotos\\" + imageDefault),
                    Role   = role.Result[0].Text,
                });
            }


            foreach (var item in users)
            {
                var role  = _usersRole.GetRole(_userManager, _roleManager, item.ID);
                var email = ListUsers.Where(u => u.Id == item.ApplicationUserId);

                //IEnumerable<InputModelRegistrar> Users0 = userList.Where(user => user.Id == ApplicationUserId);
                //userList.Where(user => user.Id == applicationUserId);
                //como relleno los datos de userList
                userList.Add(new InputModelRegistrar
                {
                    Email  = email.ElementAt(0).Email,
                    Imagen = item.Imagen,
                    Role   = item.Role,
                });
            }

            /*
             * foreach (var item in userLista)
             * {
             *  if (item.Imagen == null)
             *  {
             *      item.Imagen = "default.png";
             *  }
             * }
             */



            //aqui es donde vamos a realizar la comprobación por Id de usuario


            return(userList);
        }