コード例 #1
0
 /// <summary>
 /// Handle event click Select All button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BtnSelectAll_Click(object sender, EventArgs e)
 {
     if (this.mode == MODE_APPROVE)
     {
         if (MessageBox.Show(
                 "Bạn có chắc chắn muốn phê duyệt đơn nhập hàng này?",
                 "Xác nhận",
                 MessageBoxButtons.YesNo,
                 MessageBoxIcon.Question) == DialogResult.Yes)
         {
             Models.ItemOrder temp = this.parent.quanLySanPhamDomain.listSPOrder[this.selectedIndex];
             temp.isApproved = true;
             this.parent.quanLySanPhamDomain.UpdateItemOrder(
                 this.parent.repository,
                 temp,
                 this.parent);
         }
     }
     else
     {
         for (int i = 0; i < this.listSP.Items.Count; i++)
         {
             this.listSP.Items[i].Checked = true;
         }
     }
 }
コード例 #2
0
 /// <summary>
 /// Load current order data
 /// </summary>
 /// <param name="order"></param>
 private void LoadOrderData(Models.ItemOrder order)
 {
     this.data          = order.listSP;
     this.txtDate.Text  = String.Format("{0:MM/dd/yyyy}", order.date);
     this.txtOwner.Text = order.owner;
     this.LoadData();
 }
コード例 #3
0
        /// <summary>
        /// Delete the order
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="data"></param>
        public void DeleteItemOrder(Repository.Repository repository, Models.ItemOrder data, InitPage parent)
        {
            string queryString = "update ItemOrder set isDeleted=true where id=" + data.ID;

            Console.WriteLine(queryString);
            repository.cmd.CommandText = queryString;
            try
            {
                repository.cmd.ExecuteNonQuery();
                for (int i = 0; i < data.listSP.Count; i++)
                {
                    data.listSP[i].isImportOrder = false;
                    this.UpdateSanPham(repository, data.listSP[i]);
                }
                this.LoadSanPhamOrder(repository);
                parent.LoadSPOrderCallback();

                this.LoadSanPham(repository);
                parent.dataSanPham = this.listSanPham;
                parent.LoadSanPhamCallback();
                parent.selectedBillIndex = -1;
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    "Có lỗi xảy ra trong quá trình cập nhật dữ liệu, vui lòng thử lại!\nChi tiết: " + ex.StackTrace,
                    "Lỗi",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
        }
コード例 #4
0
 public CreateSanPhamImportOrder(InitPage parent, int mode, Models.ItemOrder order, int itemOrder)
 {
     this.InitializeComponent();
     this.parent        = parent;
     this.selectedIndex = itemOrder;
     this.mode          = mode;
     this.InitFormSetting();
     this.LoadOrderData(order);
 }
コード例 #5
0
        public void LoadSanPhamOrder(Repository.Repository repository)
        {
            this.listSPOrder = new List <Models.ItemOrder>();

            string queryString = "select* from ItemOrder where isApproved = false and isDeleted = false";

            repository.cmd.CommandText = queryString;

            using (DbDataReader reader = repository.cmd.ExecuteReader())
            {
                if (!reader.HasRows)
                {
                    return;
                }
                else
                {
                    while (reader.Read())
                    {
                        Models.ItemOrder temp = new Models.ItemOrder(
                            reader.GetInt32(0),
                            reader.GetDateTime(1),
                            reader.GetString(2),
                            reader.GetInt32(3),
                            reader.GetString(4),
                            reader.GetBoolean(5));
                        this.listSPOrder.Add(temp);
                    }
                }
            }
            for (int i = 0; i < this.listSPOrder.Count; i++)
            {
                string[]           listSPID      = this.listSPOrder[i].listItemID.Trim().Split(' ');
                List <Models.Item> listOrderItem = new List <Models.Item>();
                for (int j = 0; j < listSPID.Length; j++)
                {
                    if (this.GetItemByID(repository, Convert.ToInt32(listSPID[j])).ID != -1)
                    {
                        listOrderItem.Add(this.GetItemByID(repository, Convert.ToInt32(listSPID[j])));
                    }
                }
                this.listSPOrder[i].listSP = listOrderItem;
            }
        }
コード例 #6
0
        /// <summary>
        /// Handle event click Confirm button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnOK_Click(object sender, EventArgs e)
        {
            if (this.mode == MODE_CREATE_IMPORT)
            {
                if (MessageBox.Show(
                        "Bạn có chắc muốn lập đơn nhập hàng này?",
                        "Xác nhận",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    // Get all selected Item
                    List <Models.Item> selectedItem = new List <Models.Item>();
                    for (int i = 0; i < this.listSP.Items.Count; i++)
                    {
                        if (this.listSP.Items[i].Checked)
                        {
                            selectedItem.Add(this.data[i]);
                        }
                    }

                    Models.ItemOrder temp = new Models.ItemOrder(
                        DateTime.Now,
                        this.parent.currentUser.name,
                        Models.ItemOrder.IMPORT,
                        selectedItem,
                        false);
                    this.parent.quanLySanPhamDomain.AddSanPhamImportOrder(this.parent.repository, temp, this.parent);
                }
                this.Close();
            }
            else if (this.mode == MODE_CREATE_RETURN)
            {
            }
            else if (this.mode == MODE_APPROVE)
            {
            }
        }
コード例 #7
0
        /// <summary>
        /// Add SanPham's Import Order to DB
        /// </summary>
        /// <param name="repository"></param>
        public void AddSanPhamImportOrder(Repository.Repository repository, Models.ItemOrder data, InitPage parent)
        {
            string queryString = "";

            for (int i = 0; i < data.listSP.Count; i++)
            {
                data.listSP[i].isImportOrder = true;
                this.UpdateSanPham(repository, data.listSP[i]);
            }
            queryString = "insert into ItemOrder(createddate, owner, type, listItem, isApproved) " +
                          "values('" + String.Format("{0:yyyy/MM/dd}", DateTime.Now) + "'," +
                          "'" + data.owner + "'," +
                          data.type + "," +
                          "'" + this.BuildListIDString(data.listSP) + "'" +
                          ", false)";
            Console.WriteLine(queryString);
            repository.cmd.CommandText = queryString;
            try
            {
                repository.cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    "Có lỗi xảy ra trong quá trình thêm dữ liệu, vui lòng thử lại!\nChi tiết: " + ex.StackTrace,
                    "Lỗi",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }

            this.LoadSanPhamOrder(repository);
            parent.LoadSPOrderCallback();

            this.LoadSanPham(repository);
            parent.dataSanPham = this.listSanPham;
            parent.LoadSanPhamCallback();
        }