Esempio n. 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            Add_Phone    add_Phone = new Add_Phone(_phoneConfig);
            DialogResult rs        = add_Phone.ShowDialog();

            if (rs == DialogResult.OK)
            {
                _phoneConfig = new PhoneConfig(add_Phone.PhoneName, add_Phone.PlatformName, add_Phone.PlatformVersion);
            }
        }
Esempio n. 2
0
        public Add_Phone(PhoneConfig phoneConfig)
        {
            InitializeComponent();

            if (phoneConfig != null)
            {
                textBox1.Text = phoneConfig.DeviceName;
                textBox2.Text = phoneConfig.PlatformName;
                textBox3.Text = phoneConfig.PlatformVersion;
            }
        }
Esempio n. 3
0
        public SettingsForm()
        {
            InitializeComponent();

            _config = new PhoneConfig(this);

            CallManager.StackProxy = pjsipStackProxy.Instance;

            CallManager.Config = Config;
            pjsipStackProxy.Instance.Config = Config;
            pjsipRegistrar.Instance.Config  = Config;

            //  register event for registration status change
            pjsipRegistrar.Instance.AccountStateChanged += new DAccountStateChanged(proxy_AccountStateChanged);

            //pjsipStackProxy.Instance.ConfigMore.stunServer = "stun.siol.net";

            pjsipStackProxy.Instance.initialize();
            CallManager.Initialize();
            pjsipStackProxy.Instance.MessageWaitingIndication += new DMessageWaitingNotification(Instance_MessageWaitingIndication);
        }
Esempio n. 4
0
        public SettingsForm()
        {
            InitializeComponent();

            _config = new PhoneConfig(this);

            CallManager.StackProxy = pjsipStackProxy.Instance;

            CallManager.Config = Config;
            pjsipStackProxy.Instance.Config = Config;
            pjsipRegistrar.Instance.Config = Config;

            //  register event for registration status change
            pjsipRegistrar.Instance.AccountStateChanged += new DAccountStateChanged(proxy_AccountStateChanged);

            //pjsipStackProxy.Instance.ConfigMore.stunServer = "stun.siol.net";

            pjsipStackProxy.Instance.initialize();
            CallManager.Initialize();
            pjsipStackProxy.Instance.MessageWaitingIndication += new DMessageWaitingNotification(Instance_MessageWaitingIndication);
        }
        //[CustomAuthorize(Roles = "Merchant")]
        public ActionResult CreatePoster(UploadPoster P)
        {
            if (User.IsInRole("Merchant"))
            {
                if (ModelState.IsValid)
                {
                    string user_id  = User.Identity.GetUserId();
                    var    merchant = db.Merchants.FirstOrDefault(a => a.UserID == user_id);
                    int    usecoin  = 0;
                    if (P.Type == false)
                    {
                        usecoin = Convert.ToInt32(ConfigurationManager.AppSettings["posterGeneral"]);
                    }
                    else
                    {
                        usecoin = Convert.ToInt32(ConfigurationManager.AppSettings["posterVip"]);
                    }
                    if (merchant.Coin == null || merchant.Coin < usecoin)
                    {
                        SetCallout("Tài khoản Coin không đủ để đăng tin!", "warning");
                        ViewBag.Category = new SelectList(db.Categories, "CategoryID", "Name");
                        return(View(P));
                    }

                    Price price = new Price();//lưu price
                    price.SellingPrice = P.SellingPrice;
                    price.Created      = DateTime.Now;
                    db.Prices.Add(price);//---lưu price
                    db.SaveChanges();

                    Poster poster = new Poster();//lưu poster
                    poster.CategoryID = P.CategoryID; poster.MerchantID = merchant.MerchantID;
                    poster.StatusID   = P.Quantity <= 0 ? false : true; poster.Type = P.Type;
                    poster.Created    = DateTime.Now; poster.LastChanged = DateTime.Now;
                    poster.Keyword    = P.Keyword; poster.Description = P.Description;
                    poster.Quantity   = P.Quantity; poster.PriceID = price.PriceID;
                    db.Posters.Add(poster);//---lưu poster
                    db.SaveChanges();
                    var pri = db.Prices.Where(p => p.PriceID == price.PriceID).FirstOrDefault();
                    pri.PosterID        = poster.PosterID;
                    db.Entry(pri).State = EntityState.Modified;

                    List <WebsiteThuongMaiDienTu.Models.Image> images = new List <WebsiteThuongMaiDienTu.Models.Image>();
                    for (int i = 0; i < Request.Files.Count; i++)
                    {
                        var file = Request.Files[i];

                        if (file != null && file.ContentLength > 0)
                        {
                            var fileName = Path.GetFileName(file.FileName);
                            WebsiteThuongMaiDienTu.Models.Image image = new WebsiteThuongMaiDienTu.Models.Image()//lưu tên tệp ảnh vào bảng
                            {
                                Filename  = fileName,
                                Extension = Path.GetExtension(fileName),
                                PosterID  = poster.PosterID
                            };
                            db.Images.Add(image);//---lưu tên tệp ảnh vào bảng
                            images.Add(image);

                            var path = Path.Combine(Server.MapPath("~/images/Products/"), image.Filename);
                            file.SaveAs(path);
                        }
                    }

                    if (P.CategoryID == 1)//lưu thông tin cấu hình
                    {
                        PhoneConfig phone = P.PhoneConfig;
                        phone.PosterID   = poster.PosterID;
                        phone.CategoryID = P.CategoryID;
                        db.PhoneConfigs.Add(phone);
                    }
                    else if (P.CategoryID == 2)
                    {
                        LaptopConfig laptop = P.LaptopConfig;
                        laptop.PosterID   = poster.PosterID;
                        laptop.CategoryID = P.CategoryID;
                        db.LaptopConfigs.Add(laptop);
                    }
                    else if (P.CategoryID == 3)
                    {
                        Accessory access = P.Accessory;
                        access.PosterID   = poster.PosterID;
                        access.CategoryID = P.CategoryID;
                        db.Accessories.Add(access);
                    }
                    //trừ Coin trong table Merchant
                    merchant.Coin            = merchant.Coin - usecoin;
                    db.Entry(merchant).State = EntityState.Modified;
                    //lưu vào historyusecoin
                    HistoryUseCoin huc = new HistoryUseCoin();
                    huc.MerchantID  = merchant.MerchantID;
                    huc.PosterID    = poster.PosterID;
                    huc.Description = "Đăng tin";
                    huc.Coin        = usecoin;
                    huc.Created     = poster.Created;
                    db.HistoryUseCoins.Add(huc);

                    db.SaveChanges();
                    return(RedirectToAction("ListPoster", "Poster"));
                }
                return(View(P));
            }
            else
            {
                return(RedirectToAction("Shop", "Home", new { area = "" }));
            }
        }
Esempio n. 6
0
 public StylusDriver(PhoneConfig phoneCfg)
 {
     NowPosition = new Point3D(0, 0, 0);
     Config      = phoneCfg;
 }