public void ShouldCopyItem()
    {
      // arrange
      using (var db = new Db
                        {
                          new DbItem("old root")
                            {
                              new DbItem("item") { { "Title", "Welcome!" } }
                            },
                            new DbItem("new root")
                        })
      {
        var item = db.GetItem("/sitecore/content/old root/item");
        var newRoot = db.GetItem("/sitecore/content/new root");

        // act
        var copy = item.CopyTo(newRoot, "new item");

        // assert
        db.GetItem("/sitecore/content/new root/new item").Should().NotBeNull();
        db.GetItem("/sitecore/content/new root").Children["new item"].Should().NotBeNull();
        db.GetItem("/sitecore/content/old root/item").Should().NotBeNull();
        db.GetItem("/sitecore/content/old root").Children["item"].Should().NotBeNull();

        copy["Title"].Should().Be("Welcome!");
      }
    }
 public void Create_ShouldReturnNewsRepository(NewsRepositoryFactory factory, Db db, string itemName, ID itemId)
 {
   db.Add(new DbItem(itemName, itemId, Templates.NewsFolder.ID));
   var contextItem = db.GetItem(itemId);
   var repo = factory.Create(contextItem);
   repo.Should().BeAssignableTo<INewsRepository>();
 }
Ejemplo n.º 3
0
 public void TestIfInvalidConnectionString()
 {
     var db = new Db();
     db.ConString = "Server=localhosts;Database=testdb;Uid=root;Pwd=;";//erroneous
     db.Connect();
     Assert.AreEqual(db.IsConnected(), false);
 }
 public void GetActive_ShouldReturnLanguageModelForContextLanguage(Db db, [Content]DbItem item)
 {
   var contextItem = db.GetItem(item.ID);
   Sitecore.Context.Item = contextItem;
   var activeLanguage = LanguageRepository.GetActive();
   activeLanguage.TwoLetterCode.Should().BeEquivalentTo(Context.Language.Name);
 }
    public void ShouldNotOverrideStatisticsIfSetExplicitly()
    {
      // arrange
      const string Created = "20080407T135900";
      const string CreatedBy = @"sitecore\admin";
      const string Revision = "17be5e4c-19ac-4a67-b582-d72eaa761b1c";
      const string Updated = "20140613T111309:635382547899455734";
      const string UpdatedBy = @"sitecore\editor";

      // act
      using (var db = new Db
                        {
                          new DbItem("Home")
                            {
                              { "__Created", Created }, { "__Created by", CreatedBy },
                              { "__Revision", Revision },
                              { "__Updated", Updated }, { "__Updated by", UpdatedBy }
                            }
                        })
      {
        var item = db.GetItem("/sitecore/content/home");

        // assert
        item["__Created"].Should().Be(Created);
        item["__Created by"].Should().Be(CreatedBy);
        item["__Revision"].Should().Be(Revision);
        item["__Updated"].Should().Be(Updated);
        item["__Updated by"].Should().Be(UpdatedBy);
      }
    }
        public void LazyLoading_LazyDisabledGettingParent_ReturnsConcrete()
        {
            //Arrange
            using (Db database = new Db
            {
                new Sitecore.FakeDb.DbItem("Parent") {
                    new Sitecore.FakeDb.DbItem("Target")
                }
            })
            {
                var context = Context.Create(Utilities.CreateStandardResolver());

                var fluent = new SitecoreFluentConfigurationLoader();
                var parentConfig = fluent.Add<Stub2>();
                var lazy1Config = fluent.Add<Stub1>();
                lazy1Config.Parent(x => x.Stub2).IsNotLazy();
                context.Load(fluent);

                var service = new SitecoreService(database.Database, context);

                //Act
                var target = service.GetItem<Stub1>("/sitecore/content/parent/target");
                var parent = target.Stub2;

                //Assert
                Assert.AreEqual(typeof(Stub2), parent.GetType());
                Assert.True(parent is Stub2);
            }
        }
 protected void ViewAreaRefresh(int taskid)
 {
     Db obj = new Db();
     string sql = string.Format("SELECT TestCaseArea.AreaId, TestCaseArea.AreaName, Task.TaskName FROM Task INNER JOIN TestCaseArea ON Task.TaskId = TestCaseArea.TaskId where Task.TaskId = {0} ", taskid);
     GvViewArea.DataSource = obj.fetch(sql);
     GvViewArea.DataBind();
 }
Ejemplo n.º 8
0
 public DataSourceInfo(Db db)
 {
     using (DbConnectionInfo cn = db.CreateConnection())
     {
         DataTable dt = cn.GetSchema("DataSourceInformation");
         DataRow dr = dt.Rows[0];
         CompositeIdentifierSeparatorPattern = dr["CompositeIdentifierSeparatorPattern"].IfNull(String.Empty);
         CompositeIdentifierSeparatorPattern = dr["CompositeIdentifierSeparatorPattern"].IfNull(String.Empty);
         DataSourceProductName = dr["DataSourceProductName"].IfNull(String.Empty);
         DataSourceProductVersion = dr["DataSourceProductVersion"].IfNull(String.Empty);
         GroupByBehavior = (GroupByBehavior)dr["GroupByBehavior"].IfNull(GroupByBehavior.Unknown);
         DataSourceProductVersionNormalized = dr["DataSourceProductVersionNormalized"].IfNull(String.Empty);
         IdentifierCase = (IdentifierCase)dr["IdentifierCase"].IfNull(IdentifierCase.Unknown);
         IdentifierPattern = dr["IdentifierPattern"].IfNull(String.Empty);
         OrderByColumnsInSelect = dr["OrderByColumnsInSelect"].IfNull(false);
         ParameterMarkerFormat = dr["ParameterMarkerFormat"].IfNull(String.Empty);
         ParameterMarkerPattern = dr["ParameterMarkerPattern"].IfNull(String.Empty);
         ParameterNameMaxLength = dr["ParameterNameMaxLength"].IfNull(0);
         ParameterNamePattern = dr["ParameterNamePattern"].IfNull(String.Empty);
         QuotedIdentifierCase = (IdentifierCase)dr["QuotedIdentifierCase"].IfNull(IdentifierCase.Unknown);
         QuotedIdentifierPattern = dr["QuotedIdentifierPattern"].IfNull(String.Empty);
         StatementSeparatorPattern = dr["StatementSeparatorPattern"].IfNull(String.Empty);
         StringLiteralPattern = dr["StringLiteralPattern"].IfNull(String.Empty);
         SupportedJoinOperators = (SupportedJoinOperators)dr["SupportedJoinOperators"].IfNull(SupportedJoinOperators.None);
     }
 }
    public void ShouldBeAbleToSetLayoutFieldValue()
    {
      ID itemId = ID.NewID;

      using (var db = new Db
      {
        new DbItem("page", itemId)
        {
          new DbField(FieldIDs.LayoutField)
          {
            Value = "<r/>"
          }
        }
      })
      {
        DbItem fakeItem = db.DataStorage.GetFakeItem(itemId);
        Assert.Equal("<r/>", fakeItem.Fields[FieldIDs.LayoutField].Value);

        var item = db.GetItem("/sitecore/content/page");

        var layoutField = item.Fields[FieldIDs.LayoutField];
        Assert.Equal("<r/>", layoutField.Value);

        Assert.Equal("<r/>", item[FieldIDs.LayoutField]);
        Assert.Equal("<r/>", item["__Renderings"]);

        Assert.Equal("<r/>", LayoutField.GetFieldValue(item.Fields[FieldIDs.LayoutField]));
      }
    }
 public IEnumerable<SalesOrderHeader> AllCompiled()
 {
     using (var db = new Db(ConnectionString))
     {
         return compiledAll(db).ToList();
     }
 }        
Ejemplo n.º 11
0
		public void Deserialize_DeserializesNewItem()
		{
			using (var db = new Db())
			{
				var deserializer = CreateTestDeserializer(db);

				var item = new FakeItem(
					id: Guid.NewGuid(),
					parentId: ItemIDs.ContentRoot.Guid,
					templateId: _testTemplateId.Guid,
					versions: new[]
					{
						new FakeItemVersion(1, "en", new FakeFieldValue("Hello", fieldId: _testVersionedFieldId.Guid))
					});

				var deserialized = deserializer.Deserialize(item);

				Assert.NotNull(deserialized);

				var fromDb = db.GetItem(new ID(item.Id));

				Assert.NotNull(fromDb);
				Assert.Equal("Hello", fromDb[_testVersionedFieldId]);
				Assert.Equal(item.ParentId, fromDb.ParentID.Guid);
				Assert.Equal(item.TemplateId, fromDb.TemplateID.Guid);
			}
		}
 public SalesOrderHeader GetCompiled(int id)
 {
     using (var db = new Db(ConnectionString))
     {                
         return compiledGet(db, id);                
     }
 }
 public IEnumerable<SalesOrderHeader> All()
 {
     using (var db = new Db(ConnectionString))
     {
         return db.SalesOrderHeader.ToList();
     }
 }
        public void Execute_EnforeTemplateOnlyDoesNotInheritTemplate_AbortsPipeline()
        {
            //Arrange
            var task = new EnforcedTemplateCheck();
            using (Db database = new Db
            {
                new DbTemplate(new ID(TemplateInferredTypeTaskFixture.StubInferred.TemplateId)),
                new Sitecore.FakeDb.DbItem("Target", ID.NewID, new ID(TemplateInferredTypeTaskFixture.StubInferred.TemplateId))
            })
            {
                var path = "/sitecore/content/Target";
                var item = database.GetItem(path);

                var config = new SitecoreTypeConfiguration();
                config.EnforceTemplate = SitecoreEnforceTemplate.Template;
                config.TemplateId = new ID(Guid.NewGuid());

                var typeContext = new SitecoreTypeCreationContext();
                typeContext.Item = item;

                var args = new ObjectConstructionArgs(null, typeContext, config, null, new ModelCounter());

                //Act
                task.Execute(args);

                //Assert
                Assert.IsNull(args.Result);
            }
        }
 protected void ViewMaterialsRefresh(int taskid)
 {
     Db obj = new Db();
     string sql = string.Format("SELECT Material.MaterialName, Material.Description, Material.Filepath, Task.TaskName, Material.MaterialId FROM Material INNER JOIN Task ON Material.TaskId = Task.TaskId where Task.TaskId = {0} ", taskid);
     GridView1.DataSource = obj.fetch(sql);
     GridView1.DataBind();
 }
    public void ShouldNotUpdateOriginalItemOnEditing()
    {
      // arrange
      using (var db = new Db
                        {
                          new DbItem("old root")
                            {
                              new DbItem("item") { new DbField("Title") { { "en", 1, "Hi!" } }, }
                            },
                          new DbItem("new root")
                        })
      {
        var item = db.GetItem("/sitecore/content/old root/item");
        var newRoot = db.GetItem("/sitecore/content/new root");
        var copy = item.CopyTo(newRoot, "new item");

        // act
        using (new EditContext(copy))
        {
          copy["Title"] = "Welcome!";
        }

        // assert
        db.GetItem(copy.ID)["Title"].Should().Be("Welcome!");
        db.GetItem(item.ID)["Title"].Should().Be("Hi!");
      }
    }
Ejemplo n.º 17
0
    public void GetSupportedLanguages_ShouldReturlListOfSupportedLanguages(Db db, DbItem item , string rootName)
    {
      var contextItemId = ID.NewID;
      var rootId = ID.NewID;
      var template = new DbTemplate();
      template.BaseIDs = new[]
      {
        Foundation.Multisite.Templates.Site.ID,
          Templates.LanguageSettings.ID
      };

      var languageItem = new DbItem("en");
      db.Add(languageItem);
      db.Add(new DbTemplate(Foundation.Multisite.Templates.Site.ID));
      db.Add(new DbTemplate(Templates.LanguageSettings.ID) {Fields = { { Templates.LanguageSettings.Fields.SupportedLanguages, languageItem.ID.ToString()} }});
      db.Add(template);

      var rootItem = new DbItem(rootName, rootId, template.ID){ new DbField(Templates.LanguageSettings.Fields.SupportedLanguages) { {"en", languageItem.ID.ToString()} } };

      rootItem.Add(item);
      db.Add(rootItem);
      var contextItem = db.GetItem(item.ID);
      Sitecore.Context.Item = contextItem;
      var supportedLanguages = LanguageRepository.GetSupportedLanguages();
      supportedLanguages.Count().Should().BeGreaterThan(0);
    }
Ejemplo n.º 18
0
        public void Init()
        {
            ssa =  new SuperSimpleAuth ("testing_mtgdb.info", 
                "ae132e62-570f-4ffb-87cc-b9c087b09dfb");

            mtgdb = new Db("http://127.0.0.1:8082");

            repository =  new MongoRepository ("mongodb://localhost", mtgdb, ssa);
            admin = new Admin("http://127.0.0.1:8082");

            //Super simple auth can't delete from here. 
            try
            {
                repository.AddPlaneswalker ("mtgdb_tester", 
                    "test123", "*****@*****.**");
            }
            catch(Exception e)
            {
                System.Console.WriteLine (e.Message);
            }

            User ssaUser = ssa.Authenticate ("mtgdb_tester", 
                "test123", "127.0.0.1");

            mtgdbUser = new Planeswalker 
            {
                UserName = ssaUser.UserName,
                AuthToken = ssaUser.AuthToken,
                Email = ssaUser.Email,
                Id = ssaUser.Id,
                Claims = ssaUser.Claims,
                Roles = ssaUser.Roles,
                Profile = repository.GetProfile (ssaUser.Id)
            };
        }
Ejemplo n.º 19
0
 public static void Main(string[] args)
 {
     var db = new Db();
     if (!db.Hotels.Any())
     {
         InitData(db);
     }
     while (true)
     {
         Console.WriteLine("请输入半径:");
         var limit = Console.ReadLine();
         var intLimit = 0;
         TryParse(limit, out intLimit);
         Console.WriteLine("请输入坐标:xxx,xxx");
         var locs = Console.ReadLine();
         var locsSps = locs?.Split(',');
         if (locsSps?.Length != 2)
         {
             continue;
         }
         var point = DbGeography.PointFromText($"Point({locsSps[0]} {locsSps[1]})", 4326);
         var query = db.Hotels.Where(_ => _.Geo.Distance(point) < intLimit).ToList();
         Console.WriteLine("符合条件的有:");
         foreach (var hotel in query)
         {
             Console.WriteLine($"Name:{hotel.Name},Point:{hotel.Geo.Longitude},{hotel.Geo.Latitude}");
         }
     }
     
 }
Ejemplo n.º 20
0
    public void LoadProfiles_SettingWithProfiles_ShouldReturnExistentProfilesEnumerable(Db db, CurrentInteraction currentInteraction, ITracker tracker, Analytics.Tracking.Profile profile)
    {
      var profileItem = new DbItem("profile", ID.NewID, new TemplateID(ProfileItem.TemplateID));
      db.Add(profileItem);
      var profileSettingItem = new DbItem("profileSetting", ID.NewID, new TemplateID(Templates.ProfilingSettings.ID))
                               {
                                 {Templates.ProfilingSettings.Fields.SiteProfiles, profileItem.ID.ToString()}
                               };
      db.Add(profileSettingItem);

      var provider = new ProfileProvider();

      var fakeSiteContext = new FakeSiteContext(new StringDictionary
                                                {
                                                  {"rootPath", "/sitecore"},
                                                  {"startItem", profileSettingItem.FullPath.Remove(0, "/sitecore".Length)}
                                                })
                            {
                              Database = db.Database
                            };


      using (new SiteContextSwitcher(fakeSiteContext))
      {
        var siteProfiles = provider.GetSiteProfiles();
        siteProfiles.Count().Should().Be(1);
      }
    }
Ejemplo n.º 21
0
 public void ShouldCreateTemplateFieldItemBasedOnDbField(ID templateId, DbField field)
 {
   using (var db = new Db { new DbTemplate(templateId) { field } })
   {
     db.GetItem(field.ID).Should().NotBeNull();
   }
 }
 protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
 {
     Db db = new Db();
     GridView1.DataSource = db.Fetch(string.Format("select * from emp where job = '{0}'", DropDownList1.SelectedValue));
     GridView1.DataBind();
     lblCnt.Text = GridView1.Rows.Count.ToString();
 }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Db obj = new Db();
            //    string designation = obj.Fetchdesig(Txtuser.Text, Txtpwd.Text);
            DataTable tab = obj.FetchEmployeeDetails(Txtuser.Text, Txtpwd.Text);
            if (tab.Rows.Count > 0)
            {
                //try
                //{
                Session["EmployeeId"] = tab.Rows[0][0].ToString();
                Session["EmployeeName"] = tab.Rows[0][1].ToString();
                string designation = tab.Rows[0][2].ToString();

                // string employeeid = obj.FetchEmployeeId(Txtuser.Text, Txtpwd.Text);
                //  Session["EmployeeId"] = employeeid;
                if (designation == "Manager")
                {
                    Response.Redirect("ManagerHomePage.aspx");
                }
                else if (designation == "Developer")
                {
                    Response.Redirect("DeveloperHomePage.aspx");
                }
                else
                {
                    Response.Redirect("TesterHomePage.aspx");

                }
            }
            else
            {
                //Response.Write("Login Failed, try again");
                msg.InnerText= "login failed try again";
            }
        }
Ejemplo n.º 24
0
            public Parameters([NotNull] HttpContext c, [NotNull] Db db)
            {
                _c = c;
                _db = db;

                Set();
            }
Ejemplo n.º 25
0
 public State(string projectToken, string target, Logger logger, string workingDirectory)
 {
     this.projectToken = projectToken;
     this.target = (target != null) ? target : Constants.DEFAULT_TARGET;
     this.logger = (logger != null) ? logger : new NullLogger();
     db = new Db(this.logger, workingDirectory);
 }
        public void MapToProperty_ItemIdAsGuid_ReturnsIdAsGuid()
        {
            //Assign
            string targetPath = "/sitecore/content/target";

            using (Db database = new Db
            {
                new Sitecore.FakeDb.DbItem("Target")
            })
            {
                var mapper = new SitecoreIdMapper();
                var config = new SitecoreIdConfiguration();
                var property = typeof(Stub).GetProperty("GuidId");
                var item = database.GetItem("/sitecore/content/target");

                Assert.IsNotNull(item, "Item is null, check in Sitecore that item exists");

                config.PropertyInfo = property;

                mapper.Setup(new DataMapperResolverArgs(null, config));

                var dataContext = new SitecoreDataMappingContext(null, item, null);
                var expected = item.ID.Guid;

                //Act
                var value = mapper.MapToProperty(dataContext);

                //Assert
                Assert.AreEqual(expected, value);
            }
        }
Ejemplo n.º 27
0
    public void GetDatasources_LocationSetByRelativeQuery_ShouldReturnSourcesFromSettingItem([Frozen]ISiteSettingsProvider siteSettingsProvider, [Greedy]DatasourceProvider provider, string name, string contextItemName, Db db, string settingItemName, Item item, string sourceRootName)
    {
      var contextItemId = ID.NewID;
      var contextDbItem = new DbItem(contextItemName.Replace("-", String.Empty), contextItemId);

      var rootName = sourceRootName.Replace("-", string.Empty);
      var sourceRoot = new DbItem(rootName);
      contextDbItem.Add(sourceRoot);
      db.Add(contextDbItem);
      var settingId = ID.NewID;
      var settingDbItem = new DbItem(settingItemName.Replace("-", String.Empty), settingId, Templates.DatasourceConfiguration.ID)
      {
        new DbField(Templates.DatasourceConfiguration.Fields.DatasourceLocation)
        {
          {
            "en", $"query:./{rootName}"
          }
        }
      };
      var contextItem = db.GetItem(contextItemId);
      db.Add(settingDbItem);
      var sourceRootItem = db.GetItem(sourceRoot.ID);
      var settingItem = db.GetItem(settingId);
      siteSettingsProvider.GetSetting(Arg.Any<Item>(), Arg.Any<string>(), Arg.Any<string>()).Returns(settingItem);
      var sources = provider.GetDatasourceLocations(contextItem, name);
      sources.Should().NotBeNull();
      sources.Should().Contain(sourceRootItem);
    }
Ejemplo n.º 28
0
        public void CustomDataMapper()
        {
            //Arrange
            var templateId = ID.NewID;
            using (Db database = new Db
            {
                new Sitecore.FakeDb.DbItem("Target", ID.NewID, templateId)
                {
                    new Sitecore.FakeDb.DbItem("Child1")
                }
            })
            {
                var resolver = Utilities.CreateStandardResolver();
                resolver.DataMapperFactory.Insert(0, () => new StubDataMapper());

                var context = Context.Create(resolver);
                var service = new SitecoreService(database.Database, context);

                //Act
                var result = service.GetItem<Stub>("/sitecore");

                //Assert
                Assert.AreEqual("property test", result.Property1.Value);
            }
        }
Ejemplo n.º 29
0
 public UserProfile GetUserProfile(string userName)
 {
     using (var db = new Db())
     {
         return db.UserProfiles.FirstOrDefault(u => u.UserName.ToLower() == userName.ToLower());
     }
 }
Ejemplo n.º 30
0
    public void ShouldDeepCopyItem()
    {
      // arrange
      using (var db = new Db
                        {
                          new DbItem("original") { new DbItem("child") { { "Title", "Child" } } }
                        })
      {
        var original = db.GetItem("/sitecore/content/original");
        var root = db.GetItem("/sitecore/content");

        // act
        var copy = original.CopyTo(root, "copy"); // deep is the default

        // assert
        copy.Should().NotBeNull();
        copy.Children.Should().HaveCount(1);

        var child = copy.Children.First();
        child.Fields["Title"].Should().NotBeNull("'child.Fields[\"Title\"]' should not be null");
        child.Fields["Title"].Value.Should().Be("Child");
        child.ParentID.Should().Be(copy.ID);
        child.Name.Should().Be("child");
        child.Paths.FullPath.Should().Be("/sitecore/content/copy/child");
      }
    }
Ejemplo n.º 31
0
        private void OnStorageChanged(object data)
        {
            // inefficient - set the status of every symbol based on its presence
            foreach (Tag tag in ArtifactsFilterTagList)
            {
                anim.SetSymbolVisiblity(tag.ToString(), false);
            }
            foreach (Tag tag in storage.GetAllTagsInStorage())
            {
                anim.SetSymbolVisiblity(tag.ToString(), true);
            }
            // determine appropriate decor amount
            Attributes attributes = this.GetAttributes();

            if (decorModifier.Count > 0)
            {
                foreach (AttributeModifier attr in decorModifier.Values)
                {
                    attributes.Remove(attr);
                }
                decorModifier.Clear();
            }
            // probably need a hashmap from the tag of the artifact to the decor modifier and decor radius modifier for it so I can properly remove
            // and add the components
            foreach (GameObject go in storage.items)
            {
                if (go.GetComponent <DecorProvider>() != null)
                {
                    float  decorValue  = go.GetComponent <PrimaryElement>().Units *Mathf.Max(Db.Get().BuildingAttributes.Decor.Lookup(go).GetTotalValue() * STORED_DECOR_MODIFIER, MINIMUM_DECOR_PER_ITEM);
                    string description = string.Format(STRINGS.BUILDINGS.PREFABS.ITEMPEDESTAL.DISPLAYED_ITEM_FMT, go.GetComponent <KPrefabID>().PrefabTag.ProperName());
                    Tag    prefabTag   = go.GetComponent <KPrefabID>().PrefabTag;
                    if (decorModifier.ContainsKey(prefabTag))
                    {
                        decorModifier[prefabTag].SetValue(decorModifier[prefabTag].Value + decorValue);
                    }
                    else
                    {
                        decorModifier[prefabTag] = new AttributeModifier(Db.Get().BuildingAttributes.Decor.Id, decorValue, description, false, false, true);
                    }
                }
            }
            foreach (AttributeModifier attr in decorModifier.Values)
            {
                attributes.Add(attr);
            }
        }
Ejemplo n.º 32
0
 public static UserIdentifierCollection Where(Func <UserIdentifierColumns, QueryFilter <UserIdentifierColumns> > where, OrderBy <UserIdentifierColumns> orderBy = null, Database database = null)
 {
     database = database ?? Db.For <UserIdentifier>();
     return(new UserIdentifierCollection(database.GetQuery <UserIdentifierColumns, UserIdentifier>(where, orderBy), true));
 }
Ejemplo n.º 33
0
        public void PlaceOrder()
        {
            // Get cart list
            List <CartVM> cart = Session["cart"] as List <CartVM>;

            // Get username
            string username = User.Identity.Name;

            int orderId = 0;

            using (Db db = new Db())
            {
                // Init OrderDTO
                OrderDTO orderDTO = new OrderDTO();

                // Get user id
                var query  = db.Users.FirstOrDefault(x => x.Username == username);
                int userId = query.Id;

                // Add to OrderDTO and save
                orderDTO.UserId    = userId;
                orderDTO.CreatedAt = DateTime.Now;

                db.Orders.Add(orderDTO);

                db.SaveChanges();

                // Get inserted id
                orderId = orderDTO.OrderId;

                // Init OrderDetailsDTO
                OrderDetailsDTO orderDetailsDTO = new OrderDetailsDTO();

                // Add to OrderDetailsDTO
                foreach (var item in cart)
                {
                    orderDetailsDTO.OrderId   = orderId;
                    orderDetailsDTO.UserId    = userId;
                    orderDetailsDTO.ProductId = item.ProductId;
                    orderDetailsDTO.Quantity  = item.Quantity;

                    db.OrderDetails.Add(orderDetailsDTO);

                    db.SaveChanges();
                }
            }



            /*
             * --> When user clicks checkout, admin will receive information about the order.
             * --> Order will be stored in tblOrders
             */
            // Email admin
            //var client = new SmtpClient("smtp.mailtrap.io", 2525)
            //{
            //    Credentials = new NetworkCredential("0d4dbda10c6f6e", "a37f5fbb161ccc"),
            //    EnableSsl = true
            //};
            //client.Send("*****@*****.**", "*****@*****.**", "New Order", "New Order! Order number " + orderId);

            // Reset session
            Session["cart"] = null;
        }
Ejemplo n.º 34
0
        protected void save_Click(object sender, EventArgs e)
        {
            if (valid())
            {
                DateTime Tgl  = Convert.ToDateTime(tgl.Text);
                string   RRID = LibKom.RRID(Tgl.Month, Tgl.Year);

                Db.Execute("EXEC spKomisiRewardRDaftar"
                           + " '" + RRID + "'"
                           + ",'" + Tgl + "'"
                           + ",'" + Request.QueryString["id"] + "'"
                           + ",'" + Cf.Str(ket.Text) + "'"
                           );

                Db.Execute("UPDATE MS_KOMISI_REWARD_R SET "
                           + " Project = '" + Project + "'"
                           + " WHERE NoRR = '" + RRID + "'");

                int index = 0;
                foreach (Control tr in list.Controls)
                {
                    CheckBox cb = (CheckBox)list.FindControl("cb_" + index);

                    if (cb.Checked)
                    {
                        DataTable dd = Db.Rs("SELECT * FROM MS_KOMISI_REWARD_P_DETAIL WHERE NoReward = '" + cb.Attributes["title"] + "'");
                        if (dd != null)
                        {
                            Db.Execute("EXEC spKomisiRewardRDetil"
                                       + " '" + RRID + "'"
                                       + ",'" + dd.Rows[0]["NoReward"].ToString() + "'"
                                       + ",'" + dd.Rows[0]["Reward"].ToString() + "'"
                                       );
                        }
                    }

                    index++;
                }

                DataTable rsHeader = Db.Rs("SELECT "
                                           + " NoRR"
                                           + ",CONVERT(varchar,Tgl,106) AS [Tgl. Realisasi]"
                                           + ",Ket AS [Keterangan]"
                                           + ",NoRP AS [Kode Pengajuan]"
                                           + " FROM " + Mi.DbPrefix + "MARKETINGJUAL..MS_KOMISI_REWARD_R "
                                           + " WHERE NoRR = '" + RRID + "'");

                DataTable rsDetail = Db.Rs("SELECT "
                                           + " CONVERT(VARCHAR, SN) "
                                           + " + '.  ' + NoReward"
                                           + " + '  ' + Reward "
                                           + " FROM " + Mi.DbPrefix + "MARKETINGJUAL..MS_KOMISI_REWARD_R_DETAIL a WHERE NoRR = '" + RRID + "'");

                string Ket = Cf.LogCapture(rsHeader)
                             + Cf.LogList(rsDetail, "DETAIL");

                Db.Execute("EXEC spLogKomisiRewardR"
                           + " 'DAFTAR'"
                           + ",'" + Act.UserID + "'"
                           + ",'" + Act.IP + "'"
                           + ",'" + Ket + "'"
                           + ",'" + RRID + "'"
                           );

                decimal LogID = Db.SingleDecimal("SELECT TOP 1 LogID FROM MS_KOMISI_REWARD_R_LOG ORDER BY LogID DESC");
                Db.Execute("UPDATE MS_KOMISI_REWARD_R_LOG SET Project = '" + Project + "' WHERE LogID  = " + LogID);

                Response.Redirect("RewardRRegis1.aspx?id=" + RRID);
            }
        }
Ejemplo n.º 35
0
 public Task <bool> UpdateAccountStatus(Guid id, AccountStatus status, IUnitOfWork uow = null)
 {
     return(Db.Find(m => m.Id == id).UseUow(uow).UpdateAsync(m => new AccountEntity {
         Status = status
     }));
 }
Ejemplo n.º 36
0
 public Task <AccountEntity> GetByPhone(string phone, AccountType type, Guid?tenantId)
 {
     return(Db.Find(m => m.Phone.Equals(phone) && m.Type == type && m.TenantId == tenantId).NotFilterTenant().FirstAsync());
 }
Ejemplo n.º 37
0
 public Task <AccountEntity> GetByEmail(string email, AccountType type, Guid?tenantId)
 {
     return(Db.Find(m => m.Email.Equals(email) && m.Type == type && m.TenantId == tenantId).NotFilterTenant().FirstAsync());
 }
Ejemplo n.º 38
0
 public Task <AccountEntity> GetByUserName(string userName, AccountType type, Guid?tenantId)
 {
     return(Db.Find(m => m.UserName.Equals(userName) && m.Type == type && m.TenantId == tenantId).NotFilterTenant().FirstAsync());
 }
Ejemplo n.º 39
0
 public Task <bool> UpdatePassword(Guid id, string password)
 {
     return(Db.Find(m => m.Id == id).UpdateAsync(m => new AccountEntity {
         Password = password
     }));
 }
Ejemplo n.º 40
0
        protected void Fill()
        {
            kode.Text = Request.QueryString["id"];
            tgl.Text  = Cf.Day(DateTime.Today);

            list.Controls.Clear();

            string strSql = "SELECT a.Reward, a.NoReward, b.*"
                            + " FROM MS_KOMISI_REWARD_P_DETAIL a"
                            + " INNER JOIN MS_KOMISI_REWARD b ON a.NoReward = b.NoReward"
                            + " WHERE 1=1 "
                            + " AND (SELECT COUNT(*) FROM MS_KOMISI_REWARD_R_DETAIL WHERE NoReward = a.NoReward) = 0"
                            + " AND Project = '" + Project + "'"
                            + " AND NoRP = '" + Request.QueryString["id"] + "'";

            DataTable rs = Db.Rs(strSql);

            Rpt.NoData(list, rs, "Tidak terdapat data dengan kriteria seperti tersebut diatas.");

            int index = 0;

            for (int i = 0; i < rs.Rows.Count; i++)
            {
                if (!Response.IsClientConnected)
                {
                    break;
                }

                HtmlTableRow  r = new HtmlTableRow();
                HtmlTableCell c;
                CheckBox      cb;

                cb    = new CheckBox();
                cb.ID = "cb_" + index;
                cb.Attributes["title"] = rs.Rows[i]["NoReward"].ToString();

                c = new HtmlTableCell();
                c.Controls.Add(cb);
                r.Cells.Add(c);

                c           = new HtmlTableCell();
                c.InnerHtml = rs.Rows[i]["NamaAgent"].ToString();
                r.Cells.Add(c);

                c           = new HtmlTableCell();
                c.InnerHtml = rs.Rows[i]["NoSkema"] + " (" + rs.Rows[i]["NamaSkema"] + ")";
                r.Cells.Add(c);

                c           = new HtmlTableCell();
                c.InnerHtml = Cf.Day(Convert.ToDateTime(rs.Rows[i]["PeriodeDari"])) + " s/d " + Cf.Day(Convert.ToDateTime(rs.Rows[i]["PeriodeSampai"]));
                r.Cells.Add(c);

                c           = new HtmlTableCell();
                c.InnerHtml = rs.Rows[i]["Reward"].ToString();
                r.Cells.Add(c);

                list.Controls.Add(r);

                index++;
            }
        }
 public PermissionsController(Db context)
 {
     _context = context;
 }
Ejemplo n.º 42
0
        private const int ARTIFACT_RADIUS          = 5;    // all artifacts have radius forced to 5

        protected override void OnPrefabInit()
        {
            filteredStorage = new UncategorizedFilteredStorage(this, null, null, this, true,
                                                               Db.Get().ChoreTypes.StorageFetch);
        }
Ejemplo n.º 43
0
 public void Delete(int id)
 {
     Db.DeleteById <InvoiceElement>(id);
 }
Ejemplo n.º 44
0
        private void Fill()
        {
            string strSql = "SELECT"
                            + " LogID"
                            + ",Tgl"
                            + ",Aktivitas"
                            + ",UserID"
                            + ",IP"
                            + ",(SELECT Nama FROM " + Mi.DbPrefix + "SECURITY..USERNAME WHERE UserID = " + tb.SelectedValue + ".UserID) AS Nama"
                            + ",Pk"
                            + ",Approve"
                            + " FROM " + tb.SelectedValue
                            + " WHERE Pk = '" + Pk + "' ORDER BY LogID";

            DataTable rs = Db.Rs(strSql);

            Rpt.NoData(rpt, rs, "Log file tidak tersedia.");

            for (int i = 0; i < rs.Rows.Count; i++)
            {
                if (!Response.IsClientConnected)
                {
                    break;
                }

                TableRow  r = new TableRow();
                TableCell c;

                c      = new TableCell();
                c.Text = Cf.Day(rs.Rows[i]["Tgl"]);
                c.Wrap = false;
                r.Cells.Add(c);

                c      = new TableCell();
                c.Text = Cf.Time(rs.Rows[i]["Tgl"]);
                r.Cells.Add(c);

                c      = new TableCell();
                c.Text = rs.Rows[i]["UserID"].ToString();
                r.Cells.Add(c);

                c      = new TableCell();
                c.Text = rs.Rows[i]["Nama"].ToString();
                c.Wrap = false;
                r.Cells.Add(c);

                c      = new TableCell();
                c.Text = "<a href=\"javascript:popLog('" + rs.Rows[i]["LogID"] + "','" + tb.SelectedValue + "','" + tb.SelectedItem.Text + "','" + Pk + "')\">"
                         + rs.Rows[i]["Aktivitas"].ToString()
                         + "</a>";
                r.Cells.Add(c);

                c      = new TableCell();
                c.Text = rs.Rows[i]["Pk"].ToString();
                c.Wrap = false;
                r.Cells.Add(c);

                c      = new TableCell();
                c.Text = rs.Rows[i]["Approve"].ToString();
                c.Wrap = false;
                r.Cells.Add(c);

                Rpt.Border(r);
                rpt.Rows.Add(r);
            }
        }
Ejemplo n.º 45
0
        private void termin(string Nokontrak)
        {
            TableRow  r2 = new TableRow();
            TableRow  r3 = new TableRow();
            TableRow  r4 = new TableRow();
            TableCell c2 = new TableCell();
            TableCell c3 = new TableCell();
            TableCell c4 = new TableCell();

            System.Text.StringBuilder ArrTermin = new System.Text.StringBuilder();

            int       term = Db.SingleInteger("select count(distinct termin) from ms_komisi_detail where Nokontrak ='" + Nokontrak + "'");
            DataTable rj   = Db.Rs("Select * from ms_komisi_detail where nokontrak ='" + Nokontrak + "' And Baris = 1");
            DataTable rj2  = Db.Rs("Select * from ms_komisi_detail where nokontrak ='" + Nokontrak + "' And Baris = 2");


            if (term == 1)
            {
                c2      = new TableCell();
                c2.Text = "TERMIN 1";
                r2.Cells.Add(c2);

                for (int g = 0; g < rj.Rows.Count; g++)
                {
                    c2      = new TableCell();
                    c2.Text = Cf.Num(rj.Rows[g]["NilaiKomisi"]);
                    r2.Cells.Add(c2);

                    c2      = new TableCell();
                    c2.Text = Cf.Num(Math.Round(Convert.ToDecimal(rj.Rows[g]["NilaiBayar"])));
                    r2.Cells.Add(c2);

                    c2      = new TableCell();
                    c2.Text = Cf.Day(rj.Rows[g]["TglBayar"]);
                    r2.Cells.Add(c2);
                }

                for (int h = 0; h < rj.Rows.Count; h++)
                {
                    c2      = new TableCell();
                    c2.Text = Cf.Num(rj.Rows[h]["ClosingFee"]);
                    r2.Cells.Add(c2);

                    c2      = new TableCell();
                    c2.Text = Cf.Num(Math.Round(Convert.ToDecimal(rj.Rows[h]["NilaiBayarCF"])));
                    r2.Cells.Add(c2);

                    c2      = new TableCell();
                    c2.Text = Cf.Day(rj.Rows[h]["TglBayarClosingfee"]);
                    r2.Cells.Add(c2);
                }
            }

            else if (term == 2)
            {
                c2      = new TableCell();
                c2.Text = "TERMIN 1";
                r2.Cells.Add(c2);

                c3      = new TableCell();
                c3.Text = "TERMIN 2";
                r3.Cells.Add(c3);


                for (int f = 0; f < rj.Rows.Count; f++)
                {
                    c2      = new TableCell();
                    c2.Text = Cf.Num(rj.Rows[f]["NilaiKomisi"]);
                    r2.Cells.Add(c2);

                    c2      = new TableCell();
                    c2.Text = Cf.Num(Math.Round(Convert.ToDecimal(rj.Rows[f]["NilaiBayar"])));
                    r2.Cells.Add(c2);

                    c2      = new TableCell();
                    c2.Text = Cf.Day(rj.Rows[f]["TglBayar"]);
                    r2.Cells.Add(c2);
                }

                //closingfee
                for (int h = 0; h < rj.Rows.Count; h++)
                {
                    c2         = new TableCell();
                    c2.Text    = Cf.Num(rj.Rows[h]["ClosingFee"]);
                    c2.RowSpan = 2;
                    r2.Cells.Add(c2);

                    c2         = new TableCell();
                    c2.Text    = Cf.Num(Math.Round(Convert.ToDecimal(rj.Rows[h]["NilaiBayarCF"])));
                    c2.RowSpan = 2;
                    r2.Cells.Add(c2);

                    c2         = new TableCell();
                    c2.Text    = Cf.Day(rj.Rows[h]["TglBayarClosingfee"]);
                    c2.RowSpan = 2;
                    r2.Cells.Add(c2);
                }

                for (int f2 = 0; f2 < rj2.Rows.Count; f2++)
                {
                    c3      = new TableCell();
                    c3.Text = Cf.Num(rj2.Rows[f2]["NilaiKomisi"]);
                    r3.Cells.Add(c3);

                    c3      = new TableCell();
                    c3.Text = Cf.Num(Math.Round(Convert.ToDecimal(rj2.Rows[f2]["NilaiBayar"])));
                    r3.Cells.Add(c3);

                    c3      = new TableCell();
                    c3.Text = Cf.Day(rj2.Rows[f2]["TglBayar"]);
                    r3.Cells.Add(c3);
                }
            }
            else if (term == 3)
            {
                DataTable rj3 = Db.Rs("Select * from ms_komisi_detail where nokontrak ='" + Nokontrak + "' And Baris = 3");

                c2      = new TableCell();
                c2.Text = "TERMIN 1";
                r2.Cells.Add(c2);

                c3      = new TableCell();
                c3.Text = "TERMIN 2";
                r3.Cells.Add(c3);

                c4      = new TableCell();
                c4.Text = "TERMIN 3";
                r4.Cells.Add(c4);

                for (int j = 0; j < rj.Rows.Count; j++)
                {
                    c2      = new TableCell();
                    c2.Text = Cf.Num(rj.Rows[j]["NilaiKomisi"]);
                    r2.Cells.Add(c2);

                    c2      = new TableCell();
                    c2.Text = Cf.Num(Math.Round(Convert.ToDecimal(rj.Rows[j]["NilaiBayar"])));
                    r2.Cells.Add(c2);

                    c2      = new TableCell();
                    c2.Text = Cf.Day(rj.Rows[j]["TglBayar"]);
                    r2.Cells.Add(c2);
                }

                //closingfee
                for (int h = 0; h < rj.Rows.Count; h++)
                {
                    c2         = new TableCell();
                    c2.Text    = Cf.Num(rj.Rows[h]["ClosingFee"]);
                    c2.RowSpan = 3;
                    r2.Cells.Add(c2);

                    c2         = new TableCell();
                    c2.Text    = Cf.Num(Math.Round(Convert.ToDecimal(rj.Rows[h]["NilaiBayarCF"])));
                    c2.RowSpan = 3;
                    r2.Cells.Add(c2);

                    c2         = new TableCell();
                    c2.Text    = Cf.Day(rj.Rows[h]["TglBayarClosingfee"]);
                    c2.RowSpan = 3;
                    r2.Cells.Add(c2);
                }

                for (int j2 = 0; j2 < rj2.Rows.Count; j2++)
                {
                    c3      = new TableCell();
                    c3.Text = Cf.Num(rj2.Rows[j2]["NilaiKomisi"]);
                    r3.Cells.Add(c3);

                    c3      = new TableCell();
                    c3.Text = Cf.Num(Math.Round(Convert.ToDecimal(rj2.Rows[j2]["NilaiBayar"])));
                    r3.Cells.Add(c3);

                    c3      = new TableCell();
                    c3.Text = Cf.Day(rj2.Rows[j2]["TglBayar"]);
                    r3.Cells.Add(c3);
                }

                for (int j3 = 0; j3 < rj3.Rows.Count; j3++)
                {
                    c4      = new TableCell();
                    c4.Text = Cf.Num(rj3.Rows[j3]["NilaiKomisi"]);
                    r4.Cells.Add(c4);

                    c4      = new TableCell();
                    c4.Text = Cf.Num(Math.Round(Convert.ToDecimal(rj3.Rows[j3]["NilaiBayar"])));
                    r4.Cells.Add(c4);

                    c4      = new TableCell();
                    c4.Text = Cf.Day(rj3.Rows[j3]["TglBayar"]);
                    r4.Cells.Add(c4);
                }
            }

            rpt.Rows.Add(r2);
            rpt.Rows.Add(r3);
            rpt.Rows.Add(r4);
        }
Ejemplo n.º 46
0
 public static ObjectDescriptorCollection Where(Func <ObjectDescriptorColumns, QueryFilter <ObjectDescriptorColumns> > where, OrderBy <ObjectDescriptorColumns> orderBy = null, Database database = null)
 {
     database = database ?? Db.For <ObjectDescriptor>();
     return(new ObjectDescriptorCollection(database.GetQuery <ObjectDescriptorColumns, ObjectDescriptor>(where, orderBy), true));
 }
Ejemplo n.º 47
0
        protected void pdf_Click(object sender, System.EventArgs e)
        {
            Process p = new System.Diagnostics.Process();

            string   Nama        = "Laporan Master Komisi Detail";
            string   Link        = "";
            DateTime TglGenerate = DateTime.Now;
            string   FileName    = "";
            string   FileType    = "application/pdf";
            string   UserID      = Act.UserID;
            string   IP          = Act.IP;

            Db.Execute("EXEC spLapPDFDaftar"

                       + " '" + Nama + "'"
                       + ",'" + Link + "'"
                       + ",'" + TglGenerate + "'"
                       + ",'" + IP + "'"
                       + ",'" + UserID + "'"
                       + ",'" + FileName + "'"
                       + ",'" + FileType + "'"
                       + ",'" + Convert.ToDateTime(dari.Text) + "'"
                       + ",'" + Convert.ToDateTime(sampai.Text) + "'"
                       );

            //get nomor customer terbaru
            int NoAttachment = Db.SingleInteger(
                "SELECT TOP 1 AttachmentID FROM LapPDF ORDER BY AttachmentID DESC");

            string    strSql = "SELECT * FROM ISC064_MARKETINGJUAL..LapPDF WHERE AttachmentID  = '" + NoAttachment + "'";
            DataTable rs     = Db.Rs(strSql);

            string nfilename = "MasterKomisiDetail" + NoAttachment + ".pdf";

            //update filename
            Db.Execute("UPDATE ISC064_MARKETINGJUAL..LapPDF SET FileName= '" + nfilename + "' WHERE AttachmentID = " + NoAttachment);


            //folder untuk menyimpan file pdf
            string save = Mi.PathFilePDFReport + "MasterKomisiDetail" + rs.Rows[0]["AttachmentID"] + ".pdf";

            //declare parameter
            //string Sales = agent.SelectedValue;
            string nStatusS = "";
            string nStatusA = "";
            string nStatusB = "";

            if (statusS.Checked == true)
            {
                nStatusS = statusS.Text;
            }
            else
            {
                nStatusS = "";
            }
            if (statusA.Checked == true)
            {
                nStatusA = statusA.Text;
            }
            else
            {
                nStatusA = "";
            }
            if (statusB.Checked == true)
            {
                nStatusB = statusB.Text;
            }
            else
            {
                nStatusB = "";
            }

            //link untuk download pdf
            string link = Mi.PathAlamatWeb + "komisi/LaporanPDF/PDFMasterKomisiDetail.aspx?id=" + rs.Rows[0]["AttachmentID"]
                          + "&status_s=" + nStatusS
                          + "&status_b=" + nStatusB
                          + "&status_a=" + nStatusA
                          + "&userid=" + UserID
                          + "&project=" + project.SelectedValue
                          + "&pers=" + pers.SelectedValue
            ;

            //update link
            Db.Execute("UPDATE ISC064_MARKETINGJUAL..LapPDF SET Link= '" + link + "' WHERE AttachmentID = " + NoAttachment);

            //format page
            p.StartInfo.Arguments = "--orientation landscape --page-width 8.5in --page-height 11in --margin-left 0 --margin-right 0 --margin-top 0.25cm --margin-bottom 0 " + link + " " + save;

            //panggil aplikasi untuk mengconvert pdf
            p.StartInfo.FileName = Mi.PathWkhtmlPDFReport;
            p.Start();

            //60000 -> waktu jeda lama convert pdf
            p.WaitForExit(30000);

            string Src = Mi.PathFilePDFReport + nfilename;

            Mi.DownloadPDF(this, Src, (rs.Rows[0]["FileName"]).ToString(), rs.Rows[0]["FileType"].ToString());
        }
Ejemplo n.º 48
0
        public static void Insert()
        {
            var db = Db;

            db.CodeFirst.InitTables <UinitBlukTable>();
            db.DbMaintenance.TruncateTable <UinitBlukTable>();
            db.Insertable(new List <UinitBlukTable>
            {
                new UinitBlukTable()
                {
                    Id = 1, Create = DateTime.Now, Name = "00"
                },
                new UinitBlukTable()
                {
                    Id = 2, Create = DateTime.Now, Name = "11"
                }
            }).UseSqlServer().ExecuteBlueCopy();
            var dt = db.Queryable <UinitBlukTable>().ToDataTable();

            dt.Rows[0][0] = 3;
            dt.Rows[1][0] = 4;
            dt.TableName  = "[UinitBlukTable]";
            db.Insertable(dt).UseSqlServer().ExecuteBlueCopy();
            db.Insertable(new List <UinitBlukTable2>
            {
                new UinitBlukTable2()
                {
                    Id = 5, Name = "55"
                },
                new UinitBlukTable2()
                {
                    Id = 6, Name = "66"
                }
            }).UseSqlServer().ExecuteBlueCopy();
            db.Ado.BeginTran();
            db.Insertable(new List <UinitBlukTable2>
            {
                new UinitBlukTable2()
                {
                    Id = 7, Name = "77"
                },
                new UinitBlukTable2()
                {
                    Id = 8, Name = "88"
                }
            }).UseSqlServer().ExecuteBlueCopy();
            var task = db.Insertable(new List <UinitBlukTable2>
            {
                new UinitBlukTable2()
                {
                    Id = 9, Name = "9"
                },
                new UinitBlukTable2()
                {
                    Id = 10, Name = "10"
                }
            }).UseSqlServer().ExecuteBlueCopyAsync();

            task.Wait();
            db.Ado.CommitTran();
            var list = db.Queryable <UinitBlukTable>().ToList();

            db.DbMaintenance.TruncateTable <UinitBlukTable>();
            if (string.Join("", list.Select(it => it.Id)) != "12345678910")
            {
                throw new Exception("Unit Insert");
            }
            List <UinitBlukTable> list2 = new List <UinitBlukTable>();

            for (int i = 1; i <= 20; i++)
            {
                UinitBlukTable data = new UinitBlukTable()
                {
                    Create = DateTime.Now.AddDays(-1),
                    Id     = i,
                    Name   = i % 3 == 0?"a":"b"
                };
                list2.Add(data);
            }
            list2.First().Name = null;
            db.DbMaintenance.TruncateTable <UinitBlukTable>();
            db.Insertable(new UinitBlukTable()
            {
                Id = 2, Name = "b", Create = DateTime.Now
            }).ExecuteCommand();
            var x = Db.Storageable(list2)
                    .SplitInsert(it => it.NotAny())
                    .SplitUpdate(it => it.Any())
                    .SplitDelete(it => it.Item.Id > 10)
                    .SplitIgnore(it => it.Item.Id == 1)
                    .SplitError(it => it.Item.Id == 3, "id不能等于3")
                    .SplitError(it => it.Item.Id == 4, "id不能等于4")
                    .SplitError(it => it.Item.Id == 5, "id不能等于5")
                    .SplitError(it => it.Item.Name == null, "name不能等于")
                    .WhereColumns(it => new { it.Id })
                    .ToStorage();

            x.AsDeleteable.ExecuteCommand();
            x.AsInsertable.ExecuteCommand();
            x.AsUpdateable.ExecuteCommand();
            foreach (var item in x.ErrorList)
            {
                Console.Write(item.StorageMessage + " ");
            }
            db.DbMaintenance.TruncateTable <UinitBlukTable>();
            IDemo1();
            IDemo2();
            IDemo3();
            IDemo4();
            IDemo5();
            IDemo6();
        }
Ejemplo n.º 49
0
        public List <MutualEntity> GetMutuals()
        {
            const string procedures = @"uspGet_All_Mutual";

            return(Db.ReadList(procedures, true, Make));
        }
Ejemplo n.º 50
0
        private void Fill()
        {
            string Status = "";

            if (statusA.Checked)
            {
                Status = " AND A.Status = 'A'";
            }
            if (statusB.Checked)
            {
                Status = " AND A.Status = 'B'";
            }

            string tgl   = "";
            string order = "";

            if (tglkontrak.Checked)
            {
                tgl   = "A.TglKontrak";
                order = ",A.NoKontrak";
            }

            DateTime Dari   = Convert.ToDateTime(dari.Text);
            DateTime Sampai = Convert.ToDateTime(sampai.Text);

            if (Dari > Sampai)
            {
                DateTime x = Sampai;
                Sampai = Dari;
                Dari   = x;
            }

            //string Agent = "", Agent2 = "";
            //if (agent.SelectedIndex != 0)
            //{
            //    Agent = " AND B.NoAgent = '" + agent.SelectedValue + "'";
            //    Agent2 = " AND A.NoAgent = '" + agent.SelectedValue + "'";
            //}
            //else
            //{
            //    if (UserAgent() > 0)
            //        Agent = " AND B.NoAgent = " + UserAgent();
            //}

            string Project = "";

            if (project.SelectedValue != "SEMUA")
            {
                Project = " AND A.Project = '" + project.SelectedValue + "'";
            }
            string Perusahaan = "";

            if (pers.SelectedValue != "SEMUA")
            {
                Perusahaan = " AND A.Pers = '" + pers.SelectedValue + "'";
            }
            int index = 1;

            int     no = 1;
            decimal t1 = 0;

            //string sql = "SELECT DISTINCT (NoAgent) from MS_KONTRAK A"
            //    + " where (select ISNULL(count(*),0) from MS_KOMISI where NoKontrak = A.NoKontrak) > 0"  +Project + Perusahaan;
            //DataTable sr = Db.Rs(sql);
            //decimal t1 = 0, t2 = 0;
            //for (int g = 0; g < sr.Rows.Count; g++)
            //{
            //if (!Response.IsClientConnected) break;

            //string strSql = "SELECT "
            //    + "A.NoKontrak"
            //    + ",A.TglKontrak"
            //    + ",A.NilaiDPP"
            //    + ",A.NoUnit"
            //    + ",A.Skema"
            //    + ",A.NilaiKontrak"
            //    + ",B.Nama AS Ag"
            //    + ",B.Principal"
            //    + ",B.NPWP"
            //    + ",B.Rekening"
            //    + ",A.Status"
            //    + ",A.PersenLunas"
            //    + ",C.Nama as Customer"
            //    + ",A.NoAgent"
            //    + ",A.NoStock"
            //    + " FROM MS_KONTRAK A INNER JOIN MS_AGENT B ON A.NoAgent = B.NoAgent"
            //    + " INNER JOIN MS_CUSTOMER C ON A.NoCustomer = C.NoCustomer"
            //    + " WHERE A.NoAgent= '" + sr.Rows[g]["NoAgent"] + "'"
            //    + " AND A.FlagKomisi = '1'"
            //    + Status
            //    + " AND CONVERT(varchar,A.TglKontrak,112) >= '" + Cf.Tgl112(Dari) + "'"
            //    + " AND CONVERT(varchar,A.TglKontrak,112) <= '" + Cf.Tgl112(Sampai) + "'"
            //    //+ Agent
            //    + Project
            //    + Perusahaan
            //    + " ORDER BY B.Nama"
            //    + order;
            string strSql = "SELECT b.*,d.* "
                            + ",A.NoKontrak"
                            + ",A.NoUnit"
                            + ",C.Nilai"
                            + ",B.NamaAgent"
                            + ",A.Status"
                            + ",A.PersenLunas"
                            //+ ",C.Nama as Customer"
                            + ",A.NoAgent"
                            + " FROM MS_KONTRAK A INNER JOIN MS_KOMISI B ON A.NoKontrak = B.NoKontrak"
                            + " INNER JOIN MS_KOMISI_DETAIL C ON B.NoKomisi = C.NoKomisi"
                            + " INNER JOIN MS_KOMISI_TERM D ON C.NoKomisi = D.NoKomisi"
                            //+ " WHERE A.NoAgent= '" + sr.Rows[g]["NoAgent"] + "'"
                            //+ " AND A.FlagKomisi = '1'"
                            + Status
                            + " AND CONVERT(varchar,A.TglKontrak,112) >= '" + Cf.Tgl112(Dari) + "'"
                            + " AND CONVERT(varchar,A.TglKontrak,112) <= '" + Cf.Tgl112(Sampai) + "'"
                            //+ Agent
                            + Project
                            + Perusahaan
                            + " ORDER BY B.NamaAgent"
                            + order;



            DataTable rs = Db.Rs(strSql);

            for (int i = 0; i < rs.Rows.Count; i++)
            {
                if (!Response.IsClientConnected)
                {
                    break;
                }

                TableRow        r = new TableRow();
                TableCell       c;
                TableRow        r2a;
                TableHeaderCell th2;
                Table           tb;

                r.VerticalAlign = VerticalAlign.Top;
                //r.Attributes["ondblclick"] = "popJadwalKomisi('" + rs.Rows[i]["NoKontrak"] + "')";

                //nambah no default
                //c = new TableCell();
                //c.Text = (no).ToString();
                ////c.RowSpan = 4;
                //c.HorizontalAlign = HorizontalAlign.Left;
                //r.Cells.Add(c);

                c      = new TableCell();
                c.Text = rs.Rows[i]["NoKontrak"].ToString();
                string NoKontrak = rs.Rows[i]["NoKontrak"].ToString();
                //c.RowSpan = 4;
                c.HorizontalAlign = HorizontalAlign.Left;
                r.Cells.Add(c);

                c      = new TableCell();
                c.Text = rs.Rows[i]["NoUnit"].ToString();
                //c.RowSpan = 4;
                c.HorizontalAlign = HorizontalAlign.Left;
                r.Cells.Add(c);

                c      = new TableCell();
                c.Text = rs.Rows[i]["NamaAgent"].ToString();
                //c.RowSpan = 4;
                c.HorizontalAlign = HorizontalAlign.Left;
                r.Cells.Add(c);

                c      = new TableCell();
                c.Text = rs.Rows[i]["NamaTermin"].ToString();
                //c.RowSpan = 4;
                c.HorizontalAlign = HorizontalAlign.Left;
                r.Cells.Add(c);

                c = new TableCell();
                //c.Text = Cf.Num(Convert.ToDecimal(rs.Rows[i]["Nilai"]));
                decimal NKom = (Convert.ToDecimal(rs.Rows[i]["Nilai"])); //Db.SingleDecimal("Select Nilai From MS_KOMISI_DETAIL Where NoKontrak ='" + rs.Rows[i]["NoKontrak"].ToString() + "'");
                c.Text            = Cf.Num(Math.Round(NKom));
                c.HorizontalAlign = HorizontalAlign.Left;
                r.Cells.Add(c);

                //cek syarat cair=================================================================
                string  bf      = "SELECT ISNULL(SUM(NilaiTagihan),0) FROM MS_TAGIHAN WHERE NoKontrak = '" + rs.Rows[i]["NoKontrak"].ToString() + "' AND Tipe = 'BF'";
                decimal NilaiBF = Db.SingleDecimal(bf);

                string  bbf      = "SELECT ISNULL(SUM(NilaiPelunasan),0) FROM MS_PELUNASAN a INNER JOIN MS_TAGIHAN b ON a.NoKontrak = b.NoKontrak WHERE a.NoKontrak = '" + rs.Rows[i]["NoKontrak"].ToString() + "' AND a.NoTagihan = b.NoUrut AND b.Tipe = 'BF'";
                decimal BayarBF  = Db.SingleDecimal(bbf);
                decimal PersenBF = NilaiBF != 0 ? BayarBF / NilaiBF * 100 : 0;

                string  dp      = "SELECT ISNULL(SUM(NilaiTagihan),0) FROM MS_TAGIHAN WHERE NoKontrak = '" + rs.Rows[i]["NoKontrak"].ToString() + "' AND Tipe = 'DP'";
                decimal NilaiDP = Db.SingleDecimal(dp);

                string  bdp      = "SELECT ISNULL(SUM(NilaiPelunasan),0) FROM MS_PELUNASAN a INNER JOIN MS_TAGIHAN b ON a.NoKontrak = b.NoKontrak WHERE a.NoKontrak = '" + rs.Rows[i]["NoKontrak"].ToString() + "' AND a.NoTagihan = b.NoUrut AND b.Tipe = 'DP'";
                decimal BayarDP  = Db.SingleDecimal(bdp);
                decimal PersenDP = NilaiDP != 0 ? BayarDP / NilaiDP * 100 : 0;

                string  ang      = "SELECT ISNULL(SUM(NilaiTagihan),0) FROM MS_TAGIHAN WHERE NoKontrak = '" + rs.Rows[i]["NoKontrak"].ToString() + "' AND Tipe = 'ANG'";
                decimal NilaiANG = Db.SingleDecimal(ang);

                string  bang      = "SELECT ISNULL(SUM(NilaiPelunasan),0) FROM MS_PELUNASAN a INNER JOIN MS_TAGIHAN b ON a.NoKontrak = b.NoKontrak WHERE a.NoKontrak = '" + rs.Rows[i]["NoKontrak"].ToString() + "' AND a.NoTagihan = b.NoUrut AND b.Tipe = 'ANG'";
                decimal BayarANG  = Db.SingleDecimal(bang);
                decimal PersenANG = NilaiANG != 0 ? BayarANG / NilaiANG * 100 : 0;

                decimal PersenLunas = 0;
                bool    PPJB = false, AJB = false, AKAD = false;

                string    kon  = "SELECT PersenLunas, PPJB, AJB, StatusAkad FROM MS_KONTRAK WHERE NoKontrak = '" + rs.Rows[i]["NoKontrak"].ToString() + "'";
                DataTable rkon = Db.Rs(kon);
                if (kon != null)
                {
                    PersenLunas = Convert.ToDecimal(rkon.Rows[0]["PersenLunas"]);
                    PPJB        = rkon.Rows[0]["PPJB"].ToString() != "B" ? true : false;
                    AJB         = rkon.Rows[0]["AJB"].ToString() == "D" ? true : false;
                    AKAD        = rkon.Rows[0]["StatusAkad"].ToString() == "SELESAI" ? true : false;
                }

                bool pengajuan = false;
                bool Lunas = Convert.ToBoolean(rs.Rows[i]["Lunas"]);
                bool BF = Convert.ToBoolean(rs.Rows[i]["BF"]);
                bool DP = Convert.ToBoolean(rs.Rows[i]["DP"]);
                bool ANG = Convert.ToBoolean(rs.Rows[i]["ANG"]);
                bool PPJB_ = Convert.ToBoolean(rs.Rows[i]["PPJB"]);
                bool AJB_ = Convert.ToBoolean(rs.Rows[i]["AJB"]);
                bool AKAD_ = Convert.ToBoolean(rs.Rows[i]["AKAD"]);
                int  a = 0, b = 0;
                if (!Lunas && !BF && !DP && !ANG && !PPJB_ && !AJB_ && !AKAD_)
                {
                    pengajuan = true;
                }
                else
                {
                    //Salah satu
                    if (Convert.ToInt32(rs.Rows[i]["TipeCair"]) == 1)
                    {
                        if ((Lunas && PersenLunas >= Convert.ToDecimal(rs.Rows[i]["PersenLunas"])) || (BF && PersenBF >= Convert.ToDecimal(rs.Rows[i]["PersenBF"])) || (DP && PersenDP >= Convert.ToDecimal(rs.Rows[i]["PersenDP"])) || (ANG && PersenANG >= Convert.ToDecimal(rs.Rows[i]["PersenANG"])) || (PPJB_ && PPJB) || (AJB_ && AJB) || (AKAD_ && AKAD))
                        {
                            pengajuan = true;
                        }
                    }
                    //Semua
                    else
                    {
                        if (Lunas)
                        {
                            a++;
                            if (PersenLunas >= Convert.ToDecimal(rs.Rows[i]["PersenLunas"]))
                            {
                                b++;
                            }
                        }
                        if (BF)
                        {
                            a++;
                            if (PersenBF >= Convert.ToDecimal(rs.Rows[i]["PersenBF"]))
                            {
                                b++;
                            }
                        }
                        if (DP)
                        {
                            a++;
                            if (PersenDP >= Convert.ToDecimal(rs.Rows[i]["PersenDP"]))
                            {
                                b++;
                            }
                        }
                        if (ANG)
                        {
                            a++;
                            if (PersenANG >= Convert.ToDecimal(rs.Rows[i]["PersenANG"]))
                            {
                                b++;
                            }
                        }
                        if (PPJB_)
                        {
                            a++;
                            if (PPJB)
                            {
                                b++;
                            }
                        }
                        if (AJB_)
                        {
                            a++;
                            if (AJB)
                            {
                                b++;
                            }
                        }
                        if (AKAD_)
                        {
                            a++;
                            if (AKAD)
                            {
                                b++;
                            }
                        }

                        if (a == b)
                        {
                            pengajuan = true;
                        }
                    }
                }
                //======================================================================================

                string StatusKom = "<label style='color:red;'>Belum Bisa Pengajuan</label>", NoRef = "";
                if (pengajuan)
                {
                    StatusKom = "<label style='color:yellow;'>Siap Cair</label>";
                }
                DataTable kp = Db.Rs("SELECT * FROM MS_KOMISIP_DETAIL WHERE NoKomisi = '" + rs.Rows[i]["NoKomisi"].ToString() + "' AND SN_KomisiTermin = " + Convert.ToInt32(rs.Rows[i]["SN"]));
                if (kp.Rows.Count > 0)
                {
                    NoRef     = kp.Rows[0]["NoKomisiP"].ToString();
                    StatusKom = "<label style='color:green;'>Pengajuan</label>";

                    DataTable kr = Db.Rs("SELECT * FROM MS_KOMISIR_DETAIL WHERE NoKomisi = '" + rs.Rows[i]["NoKomisi"].ToString() + "' AND SN_KomisiTermin = " + Convert.ToInt32(rs.Rows[i]["SN"]));
                    if (kr.Rows.Count > 0)
                    {
                        NoRef     = kr.Rows[0]["NoKomisiR"].ToString();
                        StatusKom = "<label style='color:blue;'>Cair</label>";
                    }
                }

                c      = new TableCell();
                c.Text = StatusKom;
                r.Cells.Add(c);
                t1 = NKom;

                rpt.Rows.Add(r);
                no++;
                SubTotal("SUB TOTAL", t1);
                //termin(NoKontrak);
            }

            //}
            //SubTotal("GRAND TOTAL", t1);
        }
Ejemplo n.º 51
0
		///<summary>Deletes one Sheet from the database.</summary>
		public static void Delete(long sheetNum){
			string command="DELETE FROM sheet "
				+"WHERE SheetNum = "+POut.Long(sheetNum);
			Db.NonQ(command);
		}
Ejemplo n.º 52
0
        public int InsertMutual(MutualEntity mutual)
        {
            const string sql = @"uspInsert_Mutual";

            return(Db.Insert(sql, true, Take(mutual)));
        }
Ejemplo n.º 53
0
        //Update record
        public static void Update(ProfileInfo o, string user)
        {
            var result = from r in Db.ProfileInfos where r.Id == o.Id select r;

            Db.SaveChanges(user);
        }
Ejemplo n.º 54
0
        public string UpdateMutual(MutualEntity mutual)
        {
            const string sql = @"uspUpdate_Mutual";

            return(Db.Update(sql, true, Take(mutual)));
        }
Ejemplo n.º 55
0
        private void InitTSBAndPlazaAndLanes()
        {
            if (null == Db)
            {
                return;
            }

            if (Db.Table <TSB>().Count() > 0)
            {
                return;                                          // already exists.
            }
            TSB        item;
            PlazaGroup plazaGroup;
            Plaza      plaza;
            Lane       lane;

            #region DIN DAENG

            #region TSB

            item           = new TSB();
            item.NetworkId = "31";
            item.TSBId     = "311";
            item.TSBNameEN = "DIN DAENG";
            item.TSBNameTH = "ดินแดง";
            item.Active    = true;
            if (!TSB.Exists(item))
            {
                TSB.Save(item);
            }

            #endregion

            #region PlazaGroup DIN DAENG

            plazaGroup = new PlazaGroup()
            {
                PlazaGroupId     = "DD",
                PlazaGroupNameEN = "DIN DAENG",
                PlazaGroupNameTH = "ดินแดง",
                Direction        = "?",
                TSBId            = item.TSBId
            };
            if (!PlazaGroup.Exists(plazaGroup))
            {
                PlazaGroup.Save(plazaGroup);
            }

            #region Plaza DIN DAENG 1

            plaza = new Plaza()
            {
                PlazaId      = "3101",
                PlazaNameEN  = "DIN DAENG 1",
                PlazaNameTH  = "ดินแดง 1",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId
            };
            if (!Plaza.Exists(plaza))
            {
                Plaza.Save(plaza);
            }

            #region Lanes

            lane = new Lane()
            {
                LaneNo       = 1,
                LaneId       = "DD01",
                LaneType     = "MTC",
                LaneAbbr     = "DD01",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId,
                PlazaId      = plaza.PlazaId
            };
            if (!Lane.Exists(lane))
            {
                Lane.Save(lane);
            }
            lane = new Lane()
            {
                LaneNo       = 2,
                LaneId       = "DD02",
                LaneType     = "MTC",
                LaneAbbr     = "DD02",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId,
                PlazaId      = plaza.PlazaId
            };
            if (!Lane.Exists(lane))
            {
                Lane.Save(lane);
            }
            lane = new Lane()
            {
                LaneNo       = 3,
                LaneId       = "DD03",
                LaneType     = "A/M",
                LaneAbbr     = "DD03",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId,
                PlazaId      = plaza.PlazaId
            };
            if (!Lane.Exists(lane))
            {
                Lane.Save(lane);
            }
            lane = new Lane()
            {
                LaneNo       = 4,
                LaneId       = "DD04",
                LaneType     = "ETC",
                LaneAbbr     = "DD04",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId,
                PlazaId      = plaza.PlazaId
            };
            if (!Lane.Exists(lane))
            {
                Lane.Save(lane);
            }

            #endregion

            #endregion

            #region Plaza DIN DAENG 2

            plaza = new Plaza()
            {
                PlazaId      = "3102",
                PlazaNameEN  = "DIN DAENG 2",
                PlazaNameTH  = "ดินแดง 2",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId
            };
            if (!Plaza.Exists(plaza))
            {
                Plaza.Save(plaza);
            }

            #region Lanes

            lane = new Lane()
            {
                LaneNo       = 11,
                LaneId       = "DD11",
                LaneType     = "?",
                LaneAbbr     = "DD11",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId,
                PlazaId      = plaza.PlazaId
            };
            if (!Lane.Exists(lane))
            {
                Lane.Save(lane);
            }
            lane = new Lane()
            {
                LaneNo       = 12,
                LaneId       = "DD12",
                LaneType     = "?",
                LaneAbbr     = "DD12",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId,
                PlazaId      = plaza.PlazaId
            };
            if (!Lane.Exists(lane))
            {
                Lane.Save(lane);
            }
            lane = new Lane()
            {
                LaneNo       = 13,
                LaneId       = "DD13",
                LaneType     = "?",
                LaneAbbr     = "DD13",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId,
                PlazaId      = plaza.PlazaId
            };
            if (!Lane.Exists(lane))
            {
                Lane.Save(lane);
            }
            lane = new Lane()
            {
                LaneNo       = 14,
                LaneId       = "DD14",
                LaneType     = "?",
                LaneAbbr     = "DD14",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId,
                PlazaId      = plaza.PlazaId
            };
            if (!Lane.Exists(lane))
            {
                Lane.Save(lane);
            }
            lane = new Lane()
            {
                LaneNo       = 15,
                LaneId       = "DD15",
                LaneType     = "?",
                LaneAbbr     = "DD15",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId,
                PlazaId      = plaza.PlazaId
            };
            if (!Lane.Exists(lane))
            {
                Lane.Save(lane);
            }
            lane = new Lane()
            {
                LaneNo       = 16,
                LaneId       = "DD16",
                LaneType     = "?",
                LaneAbbr     = "DD16",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId,
                PlazaId      = plaza.PlazaId
            };
            if (!Lane.Exists(lane))
            {
                Lane.Save(lane);
            }

            #endregion

            #endregion

            #endregion

            #endregion

            #region SUTHISARN

            #region TSB

            item           = new TSB();
            item.NetworkId = "31";
            item.TSBId     = "312";
            item.TSBNameEN = "SUTHISARN";
            item.TSBNameTH = "สุทธิสาร";
            item.Active    = false;
            if (!TSB.Exists(item))
            {
                TSB.Save(item);
            }

            #endregion

            #region PlazaGroup SUTHISARN

            plazaGroup = new PlazaGroup()
            {
                PlazaGroupId     = "SS",
                PlazaGroupNameEN = "SUTHISARN",
                PlazaGroupNameTH = "สุทธิสาร",
                Direction        = "?",
                TSBId            = item.TSBId
            };
            if (!PlazaGroup.Exists(plazaGroup))
            {
                PlazaGroup.Save(plazaGroup);
            }

            #region Plaza SUTHISARN

            plaza = new Plaza()
            {
                PlazaId      = "3103",
                PlazaNameEN  = "SUTHISARN",
                PlazaNameTH  = "สุทธิสาร",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId
            };
            if (!Plaza.Exists(plaza))
            {
                Plaza.Save(plaza);
            }

            #region Lanes

            lane = new Lane()
            {
                LaneNo       = 1,
                LaneId       = "SS01",
                LaneType     = "?",
                LaneAbbr     = "SS01",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId,
                PlazaId      = plaza.PlazaId
            };
            if (!Lane.Exists(lane))
            {
                Lane.Save(lane);
            }
            lane = new Lane()
            {
                LaneNo       = 2,
                LaneId       = "SS02",
                LaneType     = "?",
                LaneAbbr     = "SS02",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId,
                PlazaId      = plaza.PlazaId
            };
            if (!Lane.Exists(lane))
            {
                Lane.Save(lane);
            }
            lane = new Lane()
            {
                LaneNo       = 3,
                LaneId       = "SS03",
                LaneType     = "?",
                LaneAbbr     = "SS03",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId,
                PlazaId      = plaza.PlazaId
            };
            if (!Lane.Exists(lane))
            {
                Lane.Save(lane);
            }


            #endregion

            #endregion

            #endregion

            #endregion

            #region LAD PRAO

            #region TSB

            item           = new TSB();
            item.NetworkId = "31";
            item.TSBId     = "313";
            item.TSBNameEN = "LAD PRAO";
            item.TSBNameTH = "ลาดพร้าว";
            item.Active    = false;
            if (!TSB.Exists(item))
            {
                TSB.Save(item);
            }

            #endregion

            #region PlazaGroup LAD PRAO INBOUND

            plazaGroup = new PlazaGroup()
            {
                PlazaGroupId     = "LP-IN",
                PlazaGroupNameEN = "LAD PRAO INBOUND",
                PlazaGroupNameTH = "ลาดพร้าว ขาเข้า",
                Direction        = "IN",
                TSBId            = item.TSBId
            };
            if (!PlazaGroup.Exists(plazaGroup))
            {
                PlazaGroup.Save(plazaGroup);
            }

            #region Plaza LAD PRAO INBOUND

            plaza = new Plaza()
            {
                PlazaId      = "3104",
                PlazaNameEN  = "LAD PRAO INBOUND",
                PlazaNameTH  = "ลาดพร้าว ขาเข้า",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId
            };
            if (!Plaza.Exists(plaza))
            {
                Plaza.Save(plaza);
            }

            #region Lanes

            lane = new Lane()
            {
                LaneNo       = 1,
                LaneId       = "LP01",
                LaneType     = "?",
                LaneAbbr     = "LP01",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId,
                PlazaId      = plaza.PlazaId
            };
            if (!Lane.Exists(lane))
            {
                Lane.Save(lane);
            }
            lane = new Lane()
            {
                LaneNo       = 2,
                LaneId       = "LP02",
                LaneType     = "?",
                LaneAbbr     = "LP02",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId,
                PlazaId      = plaza.PlazaId
            };
            if (!Lane.Exists(lane))
            {
                Lane.Save(lane);
            }
            lane = new Lane()
            {
                LaneNo       = 3,
                LaneId       = "LP03",
                LaneType     = "?",
                LaneAbbr     = "LP03",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId,
                PlazaId      = plaza.PlazaId
            };
            if (!Lane.Exists(lane))
            {
                Lane.Save(lane);
            }
            lane = new Lane()
            {
                LaneNo       = 4,
                LaneId       = "LP04",
                LaneType     = "?",
                LaneAbbr     = "LP04",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId,
                PlazaId      = plaza.PlazaId
            };
            if (!Lane.Exists(lane))
            {
                Lane.Save(lane);
            }

            #endregion

            #endregion

            #endregion

            #region PlazaGroup LAD PRAO OUTBOUND

            plazaGroup = new PlazaGroup()
            {
                PlazaGroupId     = "LP-OUT",
                PlazaGroupNameEN = "LAD PRAO OUTBOUND",
                PlazaGroupNameTH = "ลาดพร้าว ขาออก",
                Direction        = "OUT",
                TSBId            = item.TSBId
            };
            if (!PlazaGroup.Exists(plazaGroup))
            {
                PlazaGroup.Save(plazaGroup);
            }

            #region Plaza LAD PRAO OUTBOUND

            plaza = new Plaza()
            {
                PlazaId      = "3105",
                PlazaNameEN  = "LAD PRAO OUTBOUND",
                PlazaNameTH  = "ลาดพร้าว ขาออก",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId
            };
            if (!Plaza.Exists(plaza))
            {
                Plaza.Save(plaza);
            }

            #region Lanes

            lane = new Lane()
            {
                LaneNo       = 21,
                LaneId       = "LP21",
                LaneType     = "?",
                LaneAbbr     = "LP21",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId,
                PlazaId      = plaza.PlazaId
            };
            if (!Lane.Exists(lane))
            {
                Lane.Save(lane);
            }

            lane = new Lane()
            {
                LaneNo       = 22,
                LaneId       = "LP22",
                LaneType     = "?",
                LaneAbbr     = "LP22",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId,
                PlazaId      = plaza.PlazaId
            };
            if (!Lane.Exists(lane))
            {
                Lane.Save(lane);
            }

            lane = new Lane()
            {
                LaneNo       = 23,
                LaneId       = "LP23",
                LaneType     = "?",
                LaneAbbr     = "LP23",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId,
                PlazaId      = plaza.PlazaId
            };
            if (!Lane.Exists(lane))
            {
                Lane.Save(lane);
            }

            #endregion

            #endregion

            #endregion

            #endregion

            #region RATCHADA PHISEK

            #region TSB

            item           = new TSB();
            item.NetworkId = "31";
            item.TSBId     = "314";
            item.TSBNameEN = "RATCHADA PHISEK";
            item.TSBNameTH = "รัชดาภิเษก";
            item.Active    = false;
            if (!TSB.Exists(item))
            {
                TSB.Save(item);
            }

            #endregion

            #region PlazaGroup RATCHADA PHISEK

            plazaGroup = new PlazaGroup()
            {
                PlazaGroupId     = "RP",
                PlazaGroupNameEN = "RATCHADA PHISEK",
                PlazaGroupNameTH = "รัชดาภิเษก",
                Direction        = "?",
                TSBId            = item.TSBId
            };
            if (!PlazaGroup.Exists(plazaGroup))
            {
                PlazaGroup.Save(plazaGroup);
            }

            #region Plaza RATCHADA PHISEK 1

            plaza = new Plaza()
            {
                PlazaId      = "3106",
                PlazaNameEN  = "RATCHADA PHISEK 1",
                PlazaNameTH  = "รัชดาภิเษก 1",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId
            };
            if (!Plaza.Exists(plaza))
            {
                Plaza.Save(plaza);
            }

            #region Lanes (no data)

            #endregion

            #endregion

            #region Plaza RATCHADA PHISEK 2

            plaza = new Plaza()
            {
                PlazaId      = "3107",
                PlazaNameEN  = "RATCHADA PHISEK 2",
                PlazaNameTH  = "รัชดาภิเษก 2",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId
            };
            if (!Plaza.Exists(plaza))
            {
                Plaza.Save(plaza);
            }

            #region Lanes (no data)

            #endregion

            #endregion

            #endregion

            #endregion

            #region BANGKHEN

            #region TSB

            item           = new TSB();
            item.NetworkId = "31";
            item.TSBId     = "315";
            item.TSBNameEN = "BANGKHEN";
            item.TSBNameTH = "บางเขน";
            item.Active    = false;
            if (!TSB.Exists(item))
            {
                TSB.Save(item);
            }

            #endregion

            #region PlazaGroup BANGKHEN

            plazaGroup = new PlazaGroup()
            {
                PlazaGroupId     = "BK",
                PlazaGroupNameEN = "BANGKHEN",
                PlazaGroupNameTH = "บางเขน",
                Direction        = "?",
                TSBId            = item.TSBId
            };
            if (!PlazaGroup.Exists(plazaGroup))
            {
                PlazaGroup.Save(plazaGroup);
            }

            #region Plaza BANGKHEN

            plaza = new Plaza()
            {
                PlazaId      = "3108",
                PlazaNameEN  = "BANGKHEN",
                PlazaNameTH  = "บางเขน",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId
            };
            if (!Plaza.Exists(plaza))
            {
                Plaza.Save(plaza);
            }

            #endregion

            #region Lanes (no data)

            #endregion

            #endregion

            #endregion

            #region CHANGEWATTANA

            #region TSB

            item           = new TSB();
            item.NetworkId = "31";
            item.TSBId     = "316";
            item.TSBNameEN = "CHANGEWATTANA";
            item.TSBNameTH = "แจ้งวัฒนะ";
            item.Active    = false;
            if (!TSB.Exists(item))
            {
                TSB.Save(item);
            }

            #endregion

            #region PlazaGroup CHANGEWATTANA

            plazaGroup = new PlazaGroup()
            {
                PlazaGroupId     = "CW",
                PlazaGroupNameEN = "CHANGEWATTANA",
                PlazaGroupNameTH = "แจ้งวัฒนะ",
                Direction        = "?",
                TSBId            = item.TSBId
            };
            if (!PlazaGroup.Exists(plazaGroup))
            {
                PlazaGroup.Save(plazaGroup);
            }

            #region Plaza CHANGEWATTANA 1

            plaza = new Plaza()
            {
                PlazaId      = "3109",
                PlazaNameEN  = "CHANGEWATTANA 1",
                PlazaNameTH  = "แจ้งวัฒนะ 1",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId
            };
            if (!Plaza.Exists(plaza))
            {
                Plaza.Save(plaza);
            }

            #region Lanes (no data)

            #endregion

            #endregion

            #region Plaza CHANGEWATTANA 2

            plaza = new Plaza()
            {
                PlazaId      = "3110",
                PlazaNameEN  = "CHANGEWATTANA 2",
                PlazaNameTH  = "แจ้งวัฒนะ 2",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId
            };
            if (!Plaza.Exists(plaza))
            {
                Plaza.Save(plaza);
            }

            #region Lanes (no data)

            #endregion

            #endregion

            #endregion

            #endregion

            #region LAKSI

            #region TSB

            item           = new TSB();
            item.NetworkId = "31";
            item.TSBId     = "317";
            item.TSBNameEN = "LAKSI";
            item.TSBNameTH = "หลักสี่";
            item.Active    = false;
            if (!TSB.Exists(item))
            {
                TSB.Save(item);
            }

            #endregion

            #region PlazaGroup LAKSI INBOUND

            plazaGroup = new PlazaGroup()
            {
                PlazaGroupId     = "LS-IN",
                PlazaGroupNameEN = "LAKSI INBOUND",
                PlazaGroupNameTH = "หลักสี่ ขาเข้า",
                Direction        = "IN",
                TSBId            = item.TSBId
            };
            if (!PlazaGroup.Exists(plazaGroup))
            {
                PlazaGroup.Save(plazaGroup);
            }

            #region Plaza LAKSI INBOUND

            plaza = new Plaza()
            {
                PlazaId      = "3111",
                PlazaNameEN  = "LAKSI INBOUND",
                PlazaNameTH  = "หลักสี่ ขาเข้า",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId
            };
            if (!Plaza.Exists(plaza))
            {
                Plaza.Save(plaza);
            }

            #region Lanes (no data)

            #endregion

            #endregion

            #endregion

            #region PlazaGroup LAKSI OUTBOUND

            plazaGroup = new PlazaGroup()
            {
                PlazaGroupId     = "LS-OUT",
                PlazaGroupNameEN = "LAKSI OUTBOUND",
                PlazaGroupNameTH = "หลักสี่ ขาออก",
                Direction        = "OUT",
                TSBId            = item.TSBId
            };
            if (!PlazaGroup.Exists(plazaGroup))
            {
                PlazaGroup.Save(plazaGroup);
            }

            #region Plaza LAKSI OUTBOUND

            plaza = new Plaza()
            {
                PlazaId      = "3112",
                PlazaNameEN  = "LAKSI OUTBOUND",
                PlazaNameTH  = "หลักสี่ ขาออก",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId
            };
            if (!Plaza.Exists(plaza))
            {
                Plaza.Save(plaza);
            }

            #region Lanes (no data)

            #endregion

            #endregion

            #endregion

            #endregion

            #region DON MUANG

            #region TSB

            item           = new TSB();
            item.NetworkId = "31";
            item.TSBId     = "318";
            item.TSBNameEN = "DON MUANG";
            item.TSBNameTH = "ดอนเมือง";
            item.Active    = false;
            if (!TSB.Exists(item))
            {
                TSB.Save(item);
            }

            #endregion

            #region PlazaGroup DON MUANG

            plazaGroup = new PlazaGroup()
            {
                PlazaGroupId     = "DM",
                PlazaGroupNameEN = "DON MUANG",
                PlazaGroupNameTH = "ดอนเมือง",
                Direction        = "?",
                TSBId            = item.TSBId
            };
            if (!PlazaGroup.Exists(plazaGroup))
            {
                PlazaGroup.Save(plazaGroup);
            }

            #region Plaza DON MUANG 1

            plaza = new Plaza()
            {
                PlazaId      = "3113",
                PlazaNameEN  = "DON MUANG 1",
                PlazaNameTH  = "ดอนเมือง 1",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId
            };
            if (!Plaza.Exists(plaza))
            {
                Plaza.Save(plaza);
            }

            #region Lanes (no data)

            #endregion

            #endregion

            #region Plaza DON MUANG 2

            plaza = new Plaza()
            {
                PlazaId      = "3114",
                PlazaNameEN  = "DON MUANG 2",
                PlazaNameTH  = "ดอนเมือง 2",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId
            };
            if (!Plaza.Exists(plaza))
            {
                Plaza.Save(plaza);
            }

            #region Lanes (no data)

            #endregion

            #endregion

            #endregion

            #endregion

            #region ANUSORN SATHAN

            #region TSB

            item           = new TSB();
            item.NetworkId = "31";
            item.TSBId     = "319";
            item.TSBNameEN = "ANUSORN SATHAN";
            item.TSBNameTH = "อนุสรน์สถาน";
            item.Active    = false;
            if (!TSB.Exists(item))
            {
                TSB.Save(item);
            }

            #endregion

            #region PlazaGroup ANUSORN SATHAN

            plazaGroup = new PlazaGroup()
            {
                PlazaGroupId     = "AS",
                PlazaGroupNameEN = "ANUSORN SATHAN",
                PlazaGroupNameTH = "อนุสรน์สถาน",
                Direction        = "?",
                TSBId            = item.TSBId
            };
            if (!PlazaGroup.Exists(plazaGroup))
            {
                PlazaGroup.Save(plazaGroup);
            }

            #region Plaza ANUSORN SATHAN 1

            plaza = new Plaza()
            {
                PlazaId      = "3115",
                PlazaNameEN  = "ANUSORN SATHAN 1",
                PlazaNameTH  = "อนุสรน์สถาน 1",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId
            };
            if (!Plaza.Exists(plaza))
            {
                Plaza.Save(plaza);
            }

            #region Lanes (no data)

            #endregion

            #endregion

            #region Plaza ANUSORN SATHAN 2

            plaza = new Plaza()
            {
                PlazaId      = "3116",
                PlazaNameEN  = "ANUSORN SATHAN 2",
                PlazaNameTH  = "อนุสรน์สถาน 2",
                TSBId        = item.TSBId,
                PlazaGroupId = plazaGroup.PlazaGroupId
            };
            if (!Plaza.Exists(plaza))
            {
                Plaza.Save(plaza);
            }

            #region Lanes (no data)

            #endregion

            #endregion

            #endregion

            #endregion
        }
Ejemplo n.º 56
0
        /// <summary>
        /// Save entry button
        /// Validate and save entry, force update on history
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveEntry(object sender, RoutedEventArgs e)
        {
            Entry  ob  = new Entry();
            string msg = "";

            ob.Date      = Misc.ValidDate(txtDate.Text);
            ob.EntryType = EntryType;
            ob.Time      = ValidNumber(txtTime.Text);

            // Validate data
            if (ob.Date <= 0)
            {
                msg = "Invalid date.";
            }
            else if (EntryType < 1 || EntryType > 4)
            {
                msg = "Select an entry type.";
            }
            else if (ob.Time < 0 || ob.Time > 2400)
            {
                msg = "Time must be between 0 and 2400 (military time).";
            }

            if (msg.Length > 0)
            {
                MessageBox.Show(msg);
                return;
            }

            // Set the rest of it

            ob.Glucose        = ValidNumber(txtGlucose.Text);
            ob.BaseDose       = ValidNumber(txtBaseDosage.Text);
            ob.GlucoseAdj     = ValidNumber(txtGlucoseAdjustment.Text);
            ob.FastActingDose = ValidNumber(txtTotalDose.Text);
            ob.SlowActingDose = ValidNumber(txtSlowDose.Text);
            ob.CarbGrams      = ValidNumber(txtCarbs.Text);
            ob.FoodDesc       = GetRichText(txtFoodEaten);
            ob.Notes          = GetRichText(txtNotes);
            Db.SaveEntry(ob);
            EntryDateUpdated(sender, e);

            // Show a popup if the entry is for current day, to show
            // value against week/two-week/and month averages
            if (ob.Date == Misc.DateAsInt())
            {
                var week  = Db.GetHistory(7);
                var month = Db.GetHistory(30);
                var two   = Db.GetHistory(14);

                int weekDiff  = ob.Glucose - getHist(EntryType, week);
                int twoDiff   = ob.Glucose - getHist(EntryType, two);
                int monthDiff = ob.Glucose - getHist(EntryType, month);

                MessageBox.Show("Today's Value: " + ob.Glucose +
                                "\nVs week: " + weekDiff + " (" + getHist(EntryType, week) +
                                ")\nVs two-week: " + twoDiff + " (" + getHist(EntryType, two) +
                                ")\nVs month: " + monthDiff + " (" + getHist(EntryType, month) +
                                ")\n");
            }
        }
Ejemplo n.º 57
0
        //自己特有的方法

        /// <summary>
        /// 查找到用户
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="userPwd"></param>
        /// <returns></returns>
        public UserInfo GetUserInfo(string userName, string userPwd)
        {
            return(Db.Set <UserInfo>().Where(u => u.UserName == userName && u.UserPwd == userPwd).SingleOrDefault());
        }
Ejemplo n.º 58
0
 public static void Add(ProfileInfo o, string user)
 {
     Db.ProfileInfos.Add(o);
     Db.SaveChanges(user);
 }
    public void RefreshList()
    {
        CompanyList recentInvoices = (CompanyList)RecentInvoices;

        recentInvoices.Companies = Db.SQL("SELECT i FROM Company i");
    }
Ejemplo n.º 60
0
        public ActionResult EditProduct(ProductVM model, HttpPostedFileBase file)
        {
            // Get product id
            int id = model.Id;

            // Populate categories select list and gallery images
            using (Db db = new Db())
            {
                model.Categories = new SelectList(db.Categories.ToList(), "Id", "Name");
            }
            model.GalleryImages = Directory.EnumerateFiles(Server.MapPath("~/Images/Uploads/Products/" + id + "/Gallery/Thumbs"))
                                  .Select(fn => Path.GetFileName(fn));

            // Check model state
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // Make sure product name i unique
            using (Db db = new Db())
            {
                if (db.Products.Where(x => x.Id != id).Any(x => x.Name == model.Name))
                {
                    ModelState.AddModelError("", "That product name is taken!");
                    return(View(model));
                }
            }

            // Update product
            using (Db db = new Db())
            {
                ProductDTO dto = db.Products.Find(id);
                dto.Name        = model.Name;
                dto.Slug        = model.Name.Replace(" ", "-").ToLower();
                dto.Description = model.Description;
                dto.Price       = model.Price;
                dto.CategoryId  = model.CategoryId;
                dto.ImageName   = model.ImageName;

                CategoryDTO catDTO = db.Categories.FirstOrDefault(x => x.Id == model.CategoryId);
                dto.CategoryName = catDTO.Name;

                db.SaveChanges();
            }

            // Set TempData message
            TempData["SM"] = "You have edited the product!";

            #region Image Upload

            // Chech for file upload

            if (file != null && file.ContentLength > 0)
            {
                // Get extension
                string ext = file.ContentType.ToLower();

                // Verify extension
                if (ext != "image/jpg" &&
                    ext != "image/jpeg" &&
                    ext != "image/pjpeg" &&
                    ext != "image/gif" &&
                    ext != "image/x-png" &&
                    ext != "image/png")
                {
                    using (Db db = new Db())
                    {
                        ModelState.AddModelError("", "The image was not uploaded - wrong image extension.");
                        return(View(model));
                    }
                }

                // Set upload directory paths
                var originalDirectory = new DirectoryInfo(string.Format("{0}Images\\Uploads", Server.MapPath(@"\")));

                var pathString1 = Path.Combine(originalDirectory.ToString(), "Products\\" + id.ToString());
                var pathString2 = Path.Combine(originalDirectory.ToString(), "Products\\" + id.ToString() + "\\Thumbs");

                // Delete file from directory
                DirectoryInfo di1 = new DirectoryInfo(pathString1);
                DirectoryInfo di2 = new DirectoryInfo(pathString2);

                foreach (FileInfo file2 in di1.GetFiles())
                {
                    file2.Delete();
                }

                foreach (FileInfo file3 in di2.GetFiles())
                {
                    file3.Delete();
                }

                // Save image name
                string imageName = file.FileName;

                using (Db db = new Db())
                {
                    ProductDTO dto = db.Products.Find(id);
                    dto.ImageName = imageName;

                    db.SaveChanges();
                }
                // Save original and thumb images
                var path  = string.Format("{0}\\{1}", pathString1, imageName);
                var path2 = string.Format("{0}\\{1}", pathString2, imageName);

                file.SaveAs(path);

                WebImage img = new WebImage(file.InputStream);
                img.Resize(200, 200);
                img.Save(path2);
            }

            #endregion

            // Redirect

            return(RedirectToAction("EditProduct"));
        }