コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        dbcon      db  = new dbcon();
        SqlCommand cmd = new SqlCommand();

        cmd.CommandText = "select t_id from KEY_GEN";
        SqlDataReader dr = db.executeread(cmd);

        dr.Read();
        x = dr.GetInt32(0);
        x++;
        string t_id = "TARGET" + x.ToString();

        TextBox1.Text = t_id;

        dbcon db1 = new dbcon();

        DropDownList3.Items.Add("select PRODUCT");
        SqlCommand cmd1 = new SqlCommand();

        cmd1.CommandText = "select  distinct p_name from product_tbl";
        SqlDataReader dr1 = db1.executeread(cmd1);

        while (dr1.Read())
        {
            DropDownList3.Items.Add(dr1.GetString(0));
        }
    }
コード例 #2
0
        public ActionResult ChangeStatus(int id = 0)
        {
            string str_status = "ON";

            using (dbcon db = new dbcon())
            {
                var model = db.order.Where(m => m.rowid == id).FirstOrDefault();
                if (model != null)
                {
                    str_status = model.order_status;
                }

                var           selectList = new List <SelectListItem>();
                List <status> lists      = Shop.GetStatusList();
                foreach (var item in lists)
                {
                    SelectListItem list = new SelectListItem();
                    list.Value = item.status_no;
                    list.Text  = item.status_name;
                    selectList.Add(list);
                }
                //預設選擇哪一筆
                selectList.Where(m => m.Value == str_status).First().Selected = true;

                ViewBag.SelectList = selectList;
                return(View(model));
            }
        }
コード例 #3
0
        public ActionResult EditProfile(users model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            using (dbcon db = new dbcon())
            {
                var user = db.users
                           .Where(m => m.rowid == model.rowid)
                           .FirstOrDefault();

                if (user != null)
                {
                    user.mname     = model.mname;
                    user.mnickname = model.mnickname;
                    user.memail    = model.memail;
                    user.birthday  = model.birthday;
                    user.remark    = model.remark;
                    db.SaveChanges();
                }

                return(RedirectToAction("MemberProfile"));
            }
        }
コード例 #4
0
    protected void btn1_Click(object sender, EventArgs e)
    {
        dbcon      db3  = new dbcon();
        SqlCommand cmd3 = new SqlCommand();

        cmd3.CommandText = "insert into che_tbl values(@chemistid,@che_name,@shop_name,@place,@post,@pin,@state,@district,@lan_no,@mb_no,@email,@status)";
        cmd3.Parameters.AddWithValue("@chemistid", txt1.Text);
        cmd3.Parameters.AddWithValue("@che_name", txt2.Text);
        cmd3.Parameters.AddWithValue("@shop_name", txt3.Text);
        cmd3.Parameters.AddWithValue("@place", txt4.Text);
        cmd3.Parameters.AddWithValue("@post", txt5.Text);
        cmd3.Parameters.AddWithValue("@pin", txt6.Text);
        cmd3.Parameters.AddWithValue("@state", ddl1.SelectedItem.Text);
        cmd3.Parameters.AddWithValue("@district", ddl2.SelectedItem.Text);
        cmd3.Parameters.AddWithValue("@lan_no", txt7.Text);
        cmd3.Parameters.AddWithValue("@mb_no", txt8.Text);
        cmd3.Parameters.AddWithValue("@email", txt9.Text);
        cmd3.Parameters.AddWithValue("@status", txt10.Text);
        db3.execute(cmd3);


        dbcon      db4  = new dbcon();
        SqlCommand cmd4 = new SqlCommand();

        cmd4.CommandText = "update KEY_GEN set chemistid=@chemistid";
        cmd4.Parameters.AddWithValue("@chemistid", x);
        db4.execute(cmd4);
    }
コード例 #5
0
 public ActionResult Upload(HttpPostedFileBase file)
 {
     if (file != null)
     {
         if (file.ContentLength > 0)
         {
             var pno = Shop.ProductNo;
             using (dbcon db = new dbcon())
             {
                 var product = db.product.Where(p => p.pno == pno).SingleOrDefault();
                 product.pimg = pno;
                 db.SaveChanges();
             }
             string str_folder      = string.Format("~/Content/images/product/{0}", pno);
             string str_folder_path = Server.MapPath(str_folder);
             if (!Directory.Exists(str_folder_path))
             {
                 Directory.CreateDirectory(str_folder_path);
             }
             string str_file_name = pno + ".jpg";
             var    path          = Path.Combine(str_folder_path, str_file_name);
             if (System.IO.File.Exists(path))
             {
                 System.IO.File.Delete(path);
             }
             file.SaveAs(path);
         }
     }
     return(RedirectToAction("Index"));
 }
コード例 #6
0
 public ActionResult GetDataList(int isclose)
 {
     ViewBag.isclose = isclose;
     using (dbcon db = new dbcon())
     {
         var models = db.order
                      .Join(db.payments, p => p.payment_no, d => d.payment_no,
                            (p1, d1) => new { p1, payment_name = d1.payment }).ToList();
         var models1 = models.Join(db.status, p => p.p1.order_status, d => d.status_no,
                                   (p2, d2) => new cvmGetDataList
         {
             rowid           = p2.p1.rowid,
             order_closed    = p2.p1.order_closed,
             user_no         = p2.p1.mno,
             order_no        = p2.p1.order_no,
             order_date      = p2.p1.order_date,
             status_name     = d2.status_name,
             status_no       = p2.p1.order_status,
             payment_name    = p2.payment_name,
             receive_name    = p2.p1.receive_name,
             receive_address = p2.p1.receive_address,
             remark          = p2.p1.remark
         })
                       .Where(m => m.user_no == UserAccount.UserNo)
                       .Where(m => m.order_closed == isclose)
                       .OrderByDescending(m => m.order_no).ToList();
         return(View(models1));
     }
 }
コード例 #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        dbcon      db  = new dbcon();
        SqlCommand cmd = new SqlCommand();

        cmd.CommandText = "select staffid from KEY_GEN";

        SqlDataReader dr = db.executeread(cmd);

        dr.Read();
        x = dr.GetInt32(0);
        x++;
        string staffid = "STAFF" + x.ToString();

        txt1.Text = staffid;
        cmd.Parameters.AddWithValue("@staffid", txt1.Text);
        Session["staffid"] = txt1.Text;

        txt8.Text = staffid + "*****@*****.**";
        if (!IsPostBack)
        {
            DropDownList1.Items.Add("current post");
            DropDownList1.Items.Add("RM");
            DropDownList1.Items.Add("AM");
            DropDownList1.Items.Add("PMR");
            DropDownList1.Items.Add("OFFICE ASSISTENT");
        }
    }
コード例 #8
0
        public ActionResult Edit(shippings models)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (dbcon db = new dbcon())
                {
                    if (models.rowid > 0)
                    {
                        //Edit
                        var shippings = db.shippings.Where(m => m.rowid == models.rowid).FirstOrDefault();
                        if (shippings != null)
                        {
                            shippings.shipping_no   = models.shipping_no;
                            shippings.shipping_name = models.shipping_name;
                            shippings.remark        = models.remark;
                        }
                    }
                    else
                    {
                        //Save
                        db.shippings.Add(models);
                    }
                    db.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
コード例 #9
0
ファイル: Shop.cs プロジェクト: molly41518/camping_plan
 public static List <users> GetVendorsList()
 {
     using (dbcon db = new dbcon())
     {
         return(db.users.Where(m => m.role_no == "Vendor").OrderBy(m => m.mno).ToList());
     }
 }
コード例 #10
0
ファイル: Shop.cs プロジェクト: molly41518/camping_plan
 public static string GetCategoryNameByid(int id)
 {
     using (dbcon db = new dbcon())
     {
         return(db.categorys.Where(m => m.rowid == id).FirstOrDefault().category_name);
     }
 }
コード例 #11
0
ファイル: Shop.cs プロジェクト: molly41518/camping_plan
        public static List <categorys> Getategorys(int id)
        {
            dbcon db    = new dbcon();
            var   lists = db.categorys.Where(m => m.parentid == id).OrderBy(m => m.category_no).ToList();

            return(lists);
        }
コード例 #12
0
ファイル: Shop.cs プロジェクト: molly41518/camping_plan
 public static List <status> GetStatusList()
 {
     using (dbcon db = new dbcon())
     {
         return(db.status.OrderBy(m => m.status_no).ToList());
     }
 }
コード例 #13
0
        /// <summary>
        /// 取得目前購物車筆數
        /// </summary>
        /// <returns></returns>
        private static int GetCartCount()
        {
            int int_count = 0;

            using (dbcon db = new dbcon())
            {
                if (UserAccount.IsLogin)
                {
                    var data1 = db.carts
                                .Where(m => m.mno == UserAccount.UserNo)
                                .ToList();
                    if (data1 != null)
                    {
                        int_count = data1.Count;
                    }
                }
                else
                {
                    var data2 = db.carts
                                .Where(m => m.lot_no == LotNo)
                                .ToList();
                    if (data2 != null)
                    {
                        int_count = data2.Count;
                    }
                }
            }
            return(int_count);
        }
コード例 #14
0
 //登入購物車
 public static void LoginCart()        //已經登入
 {
     if (!string.IsNullOrEmpty(LotNo)) //訪客時的批號不是空
     {
         int int_qty = 0;
         using (dbcon db = new dbcon())
         {
             var datas = db.carts
                         .Where(m => m.lot_no == LotNo) //訪客時的批號
                         .ToList();
             if (datas != null)                         //若有找到
             {
                 foreach (var item in datas)
                 {
                     int_qty = item.ptype_qty.GetValueOrDefault();               //拿到商品數量
                     AddCart(item.pno, item.ptype_no, item.ptype_spec, int_qty); //加入購物車資料庫(驗證該會員帳戶)
                     db.carts.Remove(item);                                      //刪除訪客資料
                 }
                 db.SaveChanges();
             }
         }
         LotNo = "";
     }
     ClearCustomerLotNo();
 }
コード例 #15
0
        /// <summary>
        /// 取得目前購物車金額合計
        /// </summary>
        /// <returns></returns>
        private static int GetCartTotals()
        {
            int?int_totals = 0;

            using (dbcon db = new dbcon())
            {
                if (UserAccount.IsLogin)
                {
                    var data1 = db.carts
                                .Where(m => m.mno == UserAccount.UserNo)
                                .ToList();
                    if (data1 != null)
                    {
                        int_totals = data1.Sum(m => m.amount);
                    }
                }
                else
                {
                    var data2 = db.carts
                                .Where(m => m.lot_no == LotNo)
                                .ToList();
                    if (data2 != null)
                    {
                        int_totals = data2.Sum(m => m.amount);
                    }
                }
            }
            if (int_totals == null)
            {
                int_totals = 0;
            }
            return(int_totals.GetValueOrDefault());
        }
コード例 #16
0
 public PacienteVentana(dbcon con, AccionModo accion, int id = 0)
 {
     InitializeComponent();
     db = con;
     P  = new Paciente(con);
     if (id > 0)
     {
         Modo = AccionModo.Editar;
         P.id = id;
         if (P.Cargar())
         {
             int i = 0;
             registros.ToList().ForEach(delegate(Paciente pac)
             {
                 if (pac.id == id)
                 {
                     registroSelectCombo.SelectedIndex = i;
                 }
                 i++;
             });
             save_btn.Visibility           = Visibility.Collapsed;
             cancel_btn.Visibility         = Visibility.Collapsed;
             registroSelectCombo.IsEnabled = false;
             Title = "Ver detalles de Paciente.";
         }
     }
     else
     {
         Modo = accion;
     }
 }
コード例 #17
0
 public ActionResult Upload(HttpPostedFileBase file)
 {
     if (file != null)
     {
         if (file.ContentLength > 0)
         {
             string str_folder      = string.Format("~/Content/images/product/{0}/product_type_detail/{1}", Shop.ProductNo, Shop.ProductTypeNo);
             string str_folder_path = Server.MapPath(str_folder);
             if (!Directory.Exists(str_folder_path))
             {
                 Directory.CreateDirectory(str_folder_path);
             }
             string str_file_name = Shop.ProductTypeNo + ".jpg";
             var    path          = Path.Combine(str_folder_path, str_file_name);
             if (System.IO.File.Exists(path))
             {
                 System.IO.File.Delete(path);
             }
             file.SaveAs(path);
         }
     }
     using (dbcon db = new dbcon())
     {
         var pno   = Shop.ProductNo;
         var rowid = db.product.Where(p => p.pno == pno).SingleOrDefault().rowid;
         return(RedirectToAction("Index", "ProductTypeDetail", new { id = rowid }));
     }
 }
コード例 #18
0
        public ActionResult Edit(payments models)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (dbcon db = new dbcon())
                {
                    if (models.rowid > 0)
                    {
                        //Edit
                        var payments = db.payments.Where(m => m.rowid == models.rowid).FirstOrDefault();
                        if (payments != null)
                        {
                            payments.payment_no = models.payment_no;
                            payments.payment    = models.payment;
                            payments.remark     = models.remark;
                        }
                    }
                    else
                    {
                        //Save
                        db.payments.Add(models);
                    }
                    db.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
コード例 #19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        dbcon db1 = new dbcon();

        ddl1.Items.Add("select AM");
        SqlCommand cmd1 = new SqlCommand();

        cmd1.CommandText = "select  distinct * from am_tbl";
        SqlDataReader dr1 = db1.executeread(cmd1);

        while (dr1.Read())
        {
            ddl1.Items.Add(dr1.GetString(1) + " - " + dr1.GetString(4));
        }


        string a = Request.QueryString["staffid"];

        txt1.Text = a;

        dbcon      db   = new dbcon();
        SqlCommand cmd2 = new SqlCommand();

        cmd2.CommandText = "select * from staff_tbl where staffid=@staffid";
        cmd2.Parameters.AddWithValue("@staffid", a);
        SqlDataReader dr = db.executeread(cmd2);

        dr.Read();
        txt2.Text = dr.GetString(1);
        txt3.Text = dr.GetString(7);
    }
コード例 #20
0
    protected void btn1_Click(object sender, EventArgs e)
    {
        dbcon      db3  = new dbcon();
        SqlCommand cmd3 = new SqlCommand();

        cmd3.CommandText = "insert into dr_tble values(@dr_id,@Dr_name,@specialization,@place,@pin,@state,@district,@work_in,@lan_line,@mb_no,@email)";
        cmd3.Parameters.AddWithValue("@dr_id", txt1.Text);
        cmd3.Parameters.AddWithValue("@Dr_name", txt2.Text);
        cmd3.Parameters.AddWithValue("@specialization", txt3.Text);
        cmd3.Parameters.AddWithValue("@place", txt4.Text);
        cmd3.Parameters.AddWithValue("@pin", txt5.Text);
        cmd3.Parameters.AddWithValue("@state", ddl1.SelectedItem.Text);
        cmd3.Parameters.AddWithValue("@district", ddl2.SelectedItem.Text);
        cmd3.Parameters.AddWithValue("@work_in", cbl1.SelectedItem.Text);
        cmd3.Parameters.AddWithValue("@lan_line", txt6.Text);
        cmd3.Parameters.AddWithValue("@mb_no", txt7.Text);
        cmd3.Parameters.AddWithValue("@email", txt8.Text);

        db3.execute(cmd3);


        dbcon      db4  = new dbcon();
        SqlCommand cmd4 = new SqlCommand();

        cmd4.CommandText = "update KEY_GEN set dr_id=@dr_id";
        cmd4.Parameters.AddWithValue("@dr_id", x);
        db4.execute(cmd4);
    }
        public ActionResult Edit(product_typedetail_everydaystock models)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (dbcon db = new dbcon())
                {
                    if (models.rowid > 0)
                    {
                        //Edit
                        var ptype_everydaystock = db.product_typedetail_everydaystock.Where(m => m.rowid == models.rowid).FirstOrDefault();
                        if (ptype_everydaystock != null)
                        {
                            ptype_everydaystock.stock      = models.stock;
                            ptype_everydaystock.stock_date = models.stock_date;
                        }
                    }
                    else
                    {
                        //Save
                        models.ptype_no = Shop.ProductTypeNo;
                        db.product_typedetail_everydaystock.Add(models);
                    }

                    db.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
コード例 #22
0
 public UsuariosVentana(dbcon con, Session s, string accion)
 {
     InitializeComponent();
     db      = con;
     session = s;
     preselec.ItemsSource = session.EnumerarUsuarios();
     personal             = new PersonalCollecion(db);
     personal.Reload();
     personCombo.ItemsSource = personal;
     selec = new Usuario();
     acc   = accion;
     if (accion == "ingresar")
     {
         p_select_stack.Visibility = Visibility.Collapsed;
         save_btn.IsEnabled        = false;
         save_btn.Content          = "Guardar";
         Height -= 24;
     }
     else if (accion == "editar")
     {
         save_btn.IsEnabled = false;
     }
     else if (accion == "eliminar")
     {
         edit_stack.Visibility = Visibility.Collapsed;
         Height             = 180;
         save_btn.Content   = "Eliminar";
         save_btn.IsEnabled = false;
     }
 }
コード例 #23
0
        public ActionResult GetDataList()
        {
            using (dbcon db = new dbcon())
            {
                var models = db.order
                             .Join(db.payments, p => p.payment_no, d => d.payment_no,
                                   (p1, d1) => new { p1, payment_name = d1.payment })
                             .Join(db.status, p => p.p1.order_status, d => d.status_no,
                                   (p2, d2) => new { p2, status_name = d2.status_name })
                             .Join(db.shippings, p => p.p2.p1.shipping_no, d => d.shipping_no,
                                   (p3, d3) => new
                {
                    rowid           = p3.p2.p1.rowid,
                    order_closed    = p3.p2.p1.order_closed,
                    user_no         = p3.p2.p1.mno,
                    order_no        = p3.p2.p1.order_no,
                    order_date      = p3.p2.p1.order_date,
                    status_no       = p3.p2.p1.order_status,
                    status_name     = d3.shipping_name,
                    payment_name    = p3.p2.payment_name,
                    receive_name    = p3.p2.p1.receive_name,
                    receive_address = p3.p2.p1.receive_address,
                    remark          = p3.p2.p1.remark
                })
                             .Where(m => m.user_no == UserAccount.UserNo)
                             .Where(m => m.order_closed == UserAccount.UserCode)
                             .OrderByDescending(m => m.order_no).ToList();

                return(Json(new { data = models }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #24
0
        public ActionResult Index(int id = 0, int code = -1)
        {
            UserAccount.UserStatus = id;
            if (code == -1)
            {
                if (UserAccount.UserCode == -1)
                {
                    UserAccount.UserCode = 0;
                }
            }
            else
            {
                UserAccount.UserCode = code;
            }

            if (id > 0)
            {
                using (dbcon db = new dbcon())
                {
                    string str_order_no = "";
                    var    order        = db.order.Where(m => m.rowid == id).FirstOrDefault();
                    if (order != null)
                    {
                        str_order_no = order.order_no;
                    }
                    var details = db.order_detail.Where(m => m.order_no == str_order_no).ToList();
                    ViewBag.OrderNo      = str_order_no;
                    ViewBag.order_detail = details;
                }
            }
            return(View());
        }
コード例 #25
0
 public ActionResult GetDataList()
 {
     using (dbcon db = new dbcon())
     {
         var models = db.payments.OrderBy(m => m.payment_no).ToList();
         return(Json(new { data = models }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult Create()
 {
     using (dbcon db = new dbcon())
     {
         ViewBag.ptype_no = Shop.ProductTypeNo;
         return(View());
     }
 }
コード例 #27
0
    public static int RemoveAll(string customerID)
    {
        dbcon obj = new dbcon();

        SqlParameter[] objParams = new SqlParameter[1];
        objParams[0] = new SqlParameter("@CustomerID", customerID);
        return(obj.ExecuteNonQuery("EmptyCart", objParams));
    }
コード例 #28
0
 public PersonalVentana(dbcon database, bool sessoinlimit = false)
 {
     InitializeComponent();
     db          = database;
     profesiones = new ProfesionList(db);
     agendas     = AgendaHoraria.CargarTodos(db);
     usuario     = sessoinlimit;
 }
コード例 #29
0
 public ActionResult Index(int id)
 {
     using (dbcon db = new dbcon())
     {
         Shop.Pno = db.product.Where(p => p.rowid == id).FirstOrDefault().pno;
         return(View());
     }
 }
コード例 #30
0
        public ActionResult Edit(users models)
        {
            bool status = false;

            ModelState.Remove("Password"); //忽略 Password 驗證
            ModelState.Remove("role_no");  //忽略 role_no 驗證
            if (ModelState.IsValid)
            {
                using (dbcon db = new dbcon())
                {
                    if (models.rowid > 0)
                    {
                        //Edit
                        var users = db.users.Where(m => m.rowid == models.rowid).FirstOrDefault();
                        if (users != null)
                        {
                            users.isvarify = Shop.BoolToInteger(models.bool_isvarify);
                            users.mno      = models.mno;
                            users.mname    = models.mname;
                            users.memail   = models.memail;
                            users.birthday = models.birthday;
                            users.remark   = models.remark;
                        }
                    }
                    else
                    {
                        //Save
                        models.role_no     = UserAccount.UserRoleNo;
                        models.varify_code = UserAccount.GetNewVarifyCode(); //產生驗證碼
                        if (UserAccount.UserStatus < 2)
                        {
                            models.isvarify = UserAccount.UserStatus;
                        }
                        else
                        {
                            models.isvarify = Shop.BoolToInteger(models.bool_isvarify);
                        }

                        db.users.Add(models);
                    }
                    try
                    {
                        db.Configuration.ValidateOnSaveEnabled = false;
                        db.SaveChanges();
                        db.Configuration.ValidateOnSaveEnabled = true;
                        status = true;
                    }
                    catch (Exception ex)
                    {
                        string str_message = ex.Message;
                        status = false;
                    }
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }