Esempio n. 1
0
        private void txtMaNV_TextChanged(object sender, EventArgs e)
        {
            txtPhongBan.Text = "";
            txtTenNV.Text    = "";
            WMSDataContext dc  = new WMSDataContext();
            Employee       var = (from c in dc.Employees
                                  where c.EmployeeCode == txtMaNV.Text
                                  select c).SingleOrDefault();

            if (var != null)
            {
                txtTenNV.Text    = var.Name;
                txtPhongBan.Text = var.Dept;
            }
        }
Esempio n. 2
0
        private void CalculateProductGroupRunRates()
        {
            using (WMSDataContext ctx = new WMSDataContext())
            {
                using (SqlConnection cn = new SqlConnection(Properties.Settings.Default.JDEConnectionString))
                {
                    cn.Open();
                    using (SqlCommand cmd = cn.CreateCommand())
                    {
                        int startDate = Utility.ToJulianDate(DateTime.Now.AddDays(-HistoryDays));

                        cmd.CommandText = @"SELECT LTRIM(RTRIM(SDSRP2)) AS BackendProductGroupCode, (SUM(SDSOQS) / COUNT(DISTINCT SDIVD)) AS AvgSalesPerDay
                              FROM F42119
                              WHERE SDDCTO IN ('SO','SI','SX','SW')
                              AND SDIVD >= @Date
                              GROUP BY SDSRP2";

                        cmd.Parameters.AddWithValue("@Date", startDate);
                        cmd.CommandType = System.Data.CommandType.Text;

                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                ProductGroup group = (from pg in ctx.ProductGroups
                                                      where pg.CompanyID == this.CompanyID &&
                                                      pg.BackendID == reader["BackendProductGroupCode"].ToString()
                                                      select pg).FirstOrDefault();

                                if (group == null)
                                {
                                    continue;
                                }

                                group.RunRate = reader.GetDouble(1);

                                ctx.SubmitChanges();
                            }
                        }
                    }

                    cn.Close();
                }
            }
        }
Esempio n. 3
0
        private void btnDoiMK_Click(object sender, EventArgs e)
        {
            WMSDataContext dc  = new WMSDataContext();
            User           var = (from c in dc.Users
                                  where c.UserName == taikhoan
                                  select c).SingleOrDefault();

            if (var.Password != txtMKcu.Text)
            {
                MessageBox.Show("mật khẩu cũ không đúng, vui lòng kiểm tra lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMKcu.Text = "";
                txtMKcu.Focus();
                txtMKmoi.Text        = "";
                txtMKmoixacnhan.Text = "";
            }
            else if (txtMKmoi.Text == "" || txtMKmoixacnhan.Text == "")
            {
                MessageBox.Show("Chưa nhập đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txtMKmoi.Text != txtMKmoixacnhan.Text)
            {
                MessageBox.Show("xác nhận mật khẩu không đúng, vui lòng kiểm tra lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMKcu.Text = "";
                txtMKcu.Focus();
                txtMKmoi.Text        = "";
                txtMKmoixacnhan.Text = "";
            }
            else
            {
                try
                {
                    var.Password = txtMKmoi.Text;
                    dc.SubmitChanges();
                    MessageBox.Show("Đổi mật khẩu thành công", "Thông báo", MessageBoxButtons.OK);
                    txtMKcu.Text         = "";
                    txtMKmoi.Text        = "";
                    txtMKmoixacnhan.Text = "";
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Esempio n. 4
0
 private void btn_dangnhap_Click(object sender, EventArgs e)
 {
     if (txt_taikhoan.Text == "" || txt_matkhau.Text == "")
     {
         MessageBox.Show("Chưa nhập đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txt_taikhoan.Focus();
         txt_matkhau.Clear();
     }
     else
     {
         try
         {
             WMSDataContext dc   = new WMSDataContext();
             var            item = (from c in dc.Users
                                    where c.UserName == txt_taikhoan.Text &&
                                    c.Password == txt_matkhau.Text
                                    select c).SingleOrDefault();
             if (item != null)
             {
                 TaiKhoan = txt_taikhoan.Text;
                 this.Hide();
                 var formmain = new Home(TaiKhoan);
                 formmain.Closed += (s, args) => this.Close();
                 formmain.Show();
             }
             else
             {
                 MessageBox.Show("Tài khoản hoặc mật khẩu không đúng, vui lòng kiểm tra lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 txt_taikhoan.Focus();
                 txt_matkhau.Clear();
             }
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }