private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Class_Employee emp = new Class_Employee
            {
                EmpName  = "aaa",
                HireDate = DateTime.Now,
                EmpImage = @"D:\WPFPractice2\WPFPractice2\WpfApp2\WpfApp_Class\PokemonGo\pic_001.png"
            };

            stackpanel1.DataContext = emp;
        }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
        //Response.Cache.SetCacheability(HttpCacheability.Public);
        //Response.Cache.SetValidUntilExpires(false);
        if (Request.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieAdmin"].ToString()] == null)
        {
            Response.Redirect("/adminwitcommerce/login-soft.aspx?returnUrl=" + Request.RawUrl);
        }
        else
        {
            Class_Employee emp      = new Class_Employee();
            dynamic        employee = emp.Dynamic_GetData_By_Token(Request.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieAdmin"].ToString()].Value.ToString());
            string         name     = employee.GetType().GetProperty("Name").GetValue(employee, null);
            lblEmployee.Text = name;

            //MASUKIN ROLE KE HIDDEN ID
            HiddenIDRole.Value = employee.GetType().GetProperty("IDRole").GetValue(employee, null).ToString();
        }
    }
Beispiel #3
0
    private int ImportCombination(int idProduct, string referenceCode, decimal basePrice, decimal priceBeforeImpact, decimal impactPrice, decimal PriceAfterImpact, decimal price, decimal impactWeight, decimal weight, int Quantity, int idColor, int idSize)
    {
        try
        {
            DataClassesDataContext db = new DataClassesDataContext();
            int            firstQty   = 0;
            Class_Employee emp        = new Class_Employee();
            var            employee   = emp.GetData_By_Token(HttpContext.Current.Request.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieAdmin"].ToString()].Value);

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

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

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

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

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

            return(_newData.IDProduct_Combination);
        }
        catch (Exception)
        {
            return(0);
        }
    }
Beispiel #4
0
    protected void btnImport_Click(object sender, EventArgs e)
    {
        if (fuFile.HasFile)
        {
            lblSuccess.Text = "";
            lblError.Text   = "";
            try
            {
                DataClassesDataContext db = new DataClassesDataContext();

                Class_Employee emp  = new Class_Employee();
                var            test = emp.DecryptToken(HttpContext.Current.Request.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieAdmin"].ToString()].Value);
                if (emp.DecryptToken(HttpContext.Current.Request.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieAdmin"].ToString()].Value) != null && HttpContext.Current.Request.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieAdmin"].ToString()] != null)
                {
                    fuFile.SaveAs(Server.MapPath("~/assets/import/inventory/" + fuFile.FileName));
                    StreamReader sr = new StreamReader(Server.MapPath("~/assets/import/inventory/" + fuFile.FileName));
                    try
                    {
                        CsvReader csvread = new CsvReader(sr);
                        csvread.Configuration.Delimiter       = ";";
                        csvread.Configuration.HasHeaderRecord = false;
                        char[] delimeter = { ',' };

                        List <CSV_Inventory> record = csvread.GetRecords <CSV_Inventory>().ToList();
                        int totalRead     = 0;
                        int totalNotfound = 0;
                        int totalUpdate   = 0;
                        foreach (var item in record)
                        {
                            totalRead++;
                            TBProduct_Combination data = db.TBProduct_Combinations.Where(x => !x.Deflag && x.TBProduct.ReferenceCode == item.ReferenceCodeProduct && x.ReferenceCode == item.ReferenceCodeCombination).FirstOrDefault();
                            var employee = emp.GetData_By_Token(HttpContext.Current.Request.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieAdmin"].ToString()].Value);
                            if (data != null)
                            {
                                string jenis = "";
                                data.Quantity = item.Quantity;
                                if (data.Quantity > item.Quantity)
                                {
                                    jenis = "decrease";
                                }
                                else
                                {
                                    jenis = "increase";
                                }
                                db.SP_Update_Qty(item.ReferenceCodeCombination, item.Quantity);
                                totalUpdate++;

                                TBLog_Stock log = new TBLog_Stock();
                                log.Description           = "import inventory";
                                log.IDEmployee            = employee.IDEmployee;
                                log.IDProduct_Combination = data.IDProduct_Combination;
                                log.ProductName           = data.TBProduct.Name;
                                log.UserName   = employee.Name;
                                log.Type       = jenis;
                                log.Quantity   = item.Quantity;
                                log.InsertDate = DateTime.Now;

                                db.TBLog_Stocks.InsertOnSubmit(log);
                                db.SP_Insert_LogStock("import inventory", employee.IDEmployee, data.IDProduct_Combination, data.TBProduct.Name, employee.Name, jenis, item.Quantity, DateTime.Now);
                            }
                            else
                            {
                                totalNotfound++;
                            }
                        }

                        sr.Close();
                        lblSuccess.Text += totalRead + " row(s) read, " + totalUpdate + " row(s) updated, " + totalNotfound + " row(s) not found data";
                        alertError.Style.Add(HtmlTextWriterStyle.Display, "none");
                        alertSuccess.Style.Add(HtmlTextWriterStyle.Display, "block");
                    }
                    catch (Exception ex)
                    {
                        sr.Close();
                        lblError.Text = ex.Message;
                        alertError.Style.Add(HtmlTextWriterStyle.Display, "block");
                        alertSuccess.Style.Add(HtmlTextWriterStyle.Display, "none");
                    }
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
                alertError.Style.Add(HtmlTextWriterStyle.Display, "block");
                alertSuccess.Style.Add(HtmlTextWriterStyle.Display, "none");
            }
        }
    }
Beispiel #5
0
    protected void btnImport_Click(object sender, EventArgs e)
    {
        if (fuFile.HasFile)
        {
            lblSuccess.Text = "";
            lblError.Text   = "";
            try
            {
                DataClassesDataContext db = new DataClassesDataContext();

                Class_Employee emp = new Class_Employee();
                //if (emp.DecryptToken(HttpContext.Current.Request.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieAdmin"].ToString()].Value) == null || HttpContext.Current.Request.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieAdmin"].ToString()] == null)
                {
                    fuFile.SaveAs(Server.MapPath("~/assets/import/customer/" + fuFile.FileName));
                    StreamReader sr = new StreamReader(Server.MapPath("~/assets/import/customer/" + fuFile.FileName));
                    try
                    {
                        CsvReader csvread = new CsvReader(sr);
                        csvread.Configuration.Delimiter       = ";";
                        csvread.Configuration.HasHeaderRecord = false;
                        char[] delimeter = { ',' };

                        List <CSV_Customer> record = csvread.GetRecords <CSV_Customer>().ToList();
                        int totalRead     = 0;
                        int totalNotfound = 0;
                        int totalUpdate   = 0;

                        List <TBCustomer> listCustomer = new List <TBCustomer>();
                        foreach (var item in record)
                        {
                            totalRead++;
                            TBCustomer cust = db.TBCustomers.Where(x => !x.Deflag && x.IDCustomer_Group == 1 && x.Email == item.Email).FirstOrDefault();
                            //var employee = emp.GetData_By_Token(HttpContext.Current.Request.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieAdmin"].ToString()].Value);
                            if (cust == null)
                            {
                                TBCustomer newCust = new TBCustomer();
                                newCust.FirstName = item.FirstName;
                                newCust.LastName  = item.LastName;
                                newCust.Email     = item.Email;
                                if (item.Gender == 2)
                                {
                                    newCust.Gender = "P";
                                }
                                else
                                {
                                    newCust.Gender = "L";
                                }
                                newCust.DateInsert     = DateTime.ParseExact(item.CreateDate, "dd/MM/yyyy H:mm", System.Globalization.CultureInfo.InvariantCulture);
                                newCust.DateLastUpdate = DateTime.ParseExact(item.LastUpdateDate, "dd/MM/yyyy H:mm", System.Globalization.CultureInfo.InvariantCulture);
                                if (item.Birthday != null && item.Birthday != "NULL")
                                {
                                    newCust.Birthday = DateTime.ParseExact(item.Birthday, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
                                }
                                newCust.IDCustomer_Group = 1;
                                newCust.Active           = true;
                                newCust.Password         = "";

                                //Class_Customer classCustomer = new Class_Customer();

                                //string text = item.Email + "-" + item.FirstName.Substring(0, 2);
                                //string pass = classCustomer.EncryptToken(item.Email, DateTime.Now.ToString("MMddHHmmss"));
                                //newCust.Password = pass;

                                listCustomer.Add(newCust);

                                db.SP_Insert_Customer(1, item.FirstName, item.LastName, newCust.Gender, item.Email, "", "", newCust.Birthday, true, newCust.DateInsert, newCust.DateLastUpdate);
                            }
                            else
                            {
                                totalNotfound++;
                            }
                        }

                        //db.TBCustomers.InsertAllOnSubmit(listCustomer);
                        //db.SubmitChanges();

                        foreach (var item in listCustomer)
                        {
                            Class_Customer classCustomer = new Class_Customer();
                            classCustomer.AJAX_Forget_Password(item.Email);
                        }

                        sr.Close();
                        lblSuccess.Text += totalRead + " row(s) read, " + totalUpdate + " row(s) updated, " + totalNotfound + " row(s) customer exists";
                        alertError.Style.Add(HtmlTextWriterStyle.Display, "none");
                        alertSuccess.Style.Add(HtmlTextWriterStyle.Display, "block");
                    }
                    catch (Exception ex)
                    {
                        sr.Close();
                        lblError.Text = ex.Message;
                        alertError.Style.Add(HtmlTextWriterStyle.Display, "block");
                        alertSuccess.Style.Add(HtmlTextWriterStyle.Display, "none");
                    }
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
                alertError.Style.Add(HtmlTextWriterStyle.Display, "block");
                alertSuccess.Style.Add(HtmlTextWriterStyle.Display, "none");
            }
        }
    }