private void SaleSpendRatio_Load(object sender, EventArgs e) { m_OrderSet = m_DataSet; SetupBindingSource(); var productAdapter = new VoucherExpense.DamaiDataSetTableAdapters.ProductTableAdapter(); var ingredientAdapter = new VoucherExpense.DamaiDataSetTableAdapters.IngredientTableAdapter(); var voucherAdapter = new VoucherExpense.DamaiDataSetTableAdapters.VoucherTableAdapter(); var voucherDetailAdapter = new VoucherExpense.DamaiDataSetTableAdapters.VoucherDetailTableAdapter(); productAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); ingredientAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); try { productAdapter.Fill(m_OrderSet.Product); ingredientAdapter.Fill(m_DataSet.Ingredient); voucherAdapter.Fill(m_DataSet.Voucher); voucherDetailAdapter.Fill(m_DataSet.VoucherDetail); } catch (Exception ex) { MessageBox.Show("資料庫讀取錯誤<" + ex.Message + ">, 後續操作無法進行!"); Close(); return; } cSaleItemBindingSource.DataSource = m_SaleList; this.dgViewSale.DataSource = cSaleItemBindingSource; stockItemBindingSource.DataSource = m_StockList; this.dgViewStock.DataSource = stockItemBindingSource; Reload(); }
private void ReportByVender_Load(object sender, EventArgs e) { SetupBindingSource(); var vendorAdapter = new VoucherExpense.DamaiDataSetTableAdapters.VendorTableAdapter(); var voucherAdapter = new VoucherExpense.DamaiDataSetTableAdapters.VoucherTableAdapter(); var voucherDetailAdapter = new VoucherExpense.DamaiDataSetTableAdapters.VoucherDetailTableAdapter(); var IngredientAdapter = new VoucherExpense.DamaiDataSetTableAdapters.IngredientTableAdapter(); vendorAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); IngredientAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); try { vendorAdapter.Fill(m_DataSet.Vendor); voucherAdapter.Fill(m_DataSet.Voucher); voucherDetailAdapter.Fill(m_DataSet.VoucherDetail); IngredientAdapter.Fill(m_DataSet.Ingredient); } catch (Exception ex) { MessageBox.Show("載入資料庫發生錯誤! 原因:" + ex.Message); } vendors.Add(new CNameIDForComboBox(0, " ")); foreach (var v in m_DataSet.Vendor) { vendors.Add(new CNameIDForComboBox(v.VendorID, v.Name)); } vendors.Add(new CNameIDForComboBox(int.MaxValue, "全部")); vendorIDComboBox.DataSource = vendors; cbBoxMonth.SelectedIndex = DateTime.Now.Month; this.voucherDGView.DataSource = null; // 原本先用了 vEDataSet.Voucher做格式 }
private void Voucher_Load(object sender, EventArgs e) { var accountingTitleAdapter = new VoucherExpense.DamaiDataSetTableAdapters.AccountingTitleTableAdapter(); var vendorAdapter = new VoucherExpense.DamaiDataSetTableAdapters.VendorTableAdapter(); var operatorAdapter = new VoucherExpense.DamaiDataSetTableAdapters.OperatorTableAdapter(); IngredientAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); vendorAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); operatorAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); accountingTitleAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); SetupBindingSource(); try { voucherDetailAdapter.Fill(m_DataSet.VoucherDetail); operatorAdapter.Fill(m_DataSet.Operator); IngredientAdapter.Fill(m_DataSet.Ingredient); accountingTitleAdapter.Fill(m_DataSet.AccountingTitle); vendorAdapter.Fill(m_DataSet.Vendor); voucherAdapter.Fill(m_DataSet.Voucher); MyFunction.SetControlLengthFromDB(this, m_DataSet.Voucher); } catch (Exception ex) { MessageBox.Show("載入資料出錯:" + ex.Message); } if (checkMode) { this.Text = "查核進貨"; blockEdit(); dgvVoucher.Columns["columnCheck"].ReadOnly = false; ckBoxAllowEdit.Visible = true; } if (MyFunction.LockAll) { blockEdit(); ckBoxAllowEdit.Visible = false; } if (MyFunction.IntHeaderYear != DateTime.Now.Year) { comboBoxMonth.SelectedIndex = comboBoxMonth.Items.Count - 1; } else { comboBoxMonth.SelectedIndex = DateTime.Now.Month; } // this.btnEditable.BringToFront(); BuildTitleCodeMenu(); dateTimePicker1.MaxDate = new DateTime(MyFunction.IntHeaderYear, 12, 31); dateTimePicker1.MinDate = new DateTime(MyFunction.IntHeaderYear, 1, 1); }
private void FormIngredientInventories_Load(object sender, EventArgs e) { SetupBindingSource(); dgvInventories.DataSource = inventoryBindingSource; dgvInventoryDetail.DataSource = fKInventoryDetailInventoryBindingSource; dgvProducts.DataSource = fKInventoryProductsInventoryBindingSource; var productAdapter = new VoucherExpense.DamaiDataSetTableAdapters.ProductTableAdapter(); var operatorAdapter = new VoucherExpense.DamaiDataSetTableAdapters.OperatorTableAdapter(); var ingredientAdapter = new VoucherExpense.DamaiDataSetTableAdapters.IngredientTableAdapter(); productAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); operatorAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); ingredientAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); try { productAdapter.Fill(m_OrderSet.Product); operatorAdapter.Fill(m_DataSet.Operator); ingredientAdapter.Fill(m_DataSet.Ingredient); InventoryAdapter.Fill(m_DataSet.Inventory); InventoryDetailAdapter.Fill(m_DataSet.InventoryDetail); InventoryProductsAdapter.Fill(m_DataSet.InventoryProducts); } catch (Exception ex) { MessageBox.Show("錯誤訊息:" + ex.Message); } ColumnLocked.ReadOnly = !MyFunction.LockInventory; if (MyFunction.LockInventory) { dgvColumnCurrentIn.Visible = true; dgvColumnLostMoney.Visible = true; dgvColumnPrevStockVolume.Visible = true; } else { dgvColumnCurrentIn.Visible = false; dgvColumnLostMoney.Visible = false; dgvColumnPrevStockVolume.Visible = false; } // tabControl1.DrawMode = TabDrawMode.OwnerDrawFixed; }
private void Ingredient_Load(object sender, EventArgs e) { IngredientBindingSource.DataSource = m_DataSet; vendorBindingSource.DataSource = m_DataSet; accountingTitleBindingSource.DataSource = m_DataSet; m_PhotoDirectoryExist = Directory.Exists(PhotoPath()); photoPictureBox.Visible = true; var vendorAdapter = new DamaiDataSetTableAdapters.VendorTableAdapter(); var accountingTitleAdapter = new DamaiDataSetTableAdapters.AccountingTitleTableAdapter(); IngredientAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); vendorAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); PhotoAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); accountingTitleAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); try { vendorAdapter.Fill(m_DataSet.Vendor); m_VendorList.Add(new CNameIDForComboBox(0, "")); // 提到 .Fill(vEdataSet.Ingredient)之前,要不然第一次 BindingSource.CurrentChanged會先發生 foreach (var vendor in m_DataSet.Vendor) { m_VendorList.Add(new CNameIDForComboBox(vendor.VendorID, vendor.Name)); } vendorIDComboBox.DataSource = m_VendorList; //vendorIDComboBox.ValueMember = "ID"; //vendorIDComboBox.DisplayMember = "Name"; accountingTitleAdapter.Fill(m_DataSet.AccountingTitle); IngredientAdapter.Fill(m_DataSet.Ingredient); } catch (Exception ex) { MessageBox.Show("錯誤:" + ex.Message); } MyFunction.SetFieldLength(dgvIngredient, m_DataSet.Ingredient); MyFunction.SetControlLengthFromDB(this, m_DataSet.Ingredient); }
private void FormRecipe_Load(object sender, EventArgs e) { var ingredientAdapter = new MyIngredientAdapter(); productAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); ingredientAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); recipeAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); recipeDetailAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); PhotoAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); try { recipeBindingSource.DataSource = m_DataSet; m_PhotoDirectoryExist = Directory.Exists(PhotoPath()); // fKRecipeRecipeDetailBindingSource,damaiDataSet recipeSqlBindingSource創來抄的, 實際上沒用到 fKRecipeRecipeDetailBindingSource.DataSource = recipeBindingSource; dgvRecipeDetail.DataSource = fKRecipeRecipeDetailBindingSource; productBindingSource.DataSource = m_DataSet; productAdapter.Fill(m_DataSet.Product); recipeAdapter.Fill(m_DataSet.Recipe); recipeDetailAdapter.Fill(m_DataSet.RecipeDetail); ingredientAdapter.Fill(m_DataSet.Ingredient); } catch (Exception ex) { MessageBox.Show("載入產品食材及配方錯誤!原因:" + ex.Message); } // 填給使用者選的產品表, 第一個為空白 m_ProductList = new List <CNameIDForComboBox>(); m_ProductList.Add(new CNameIDForComboBox(0, " ")); foreach (var product in m_DataSet.Product) { if (product.IsCodeNull()) { continue; } if (product.Code <= 0) { continue; } m_ProductList.Add(new CNameIDForComboBox(product.ProductID, product.Name)); } this.cNameIDForProductBindingSource.DataSource = m_ProductList; // 填 食材+配方表 (RecipeID +10000) m_SourceList = new List <CNameIDForComboBox>(); foreach (var ing in m_DataSet.Ingredient) { string name; if (ing.IsNameNull()) { name = "食材" + ing.IngredientID.ToString(); } else { name = ing.Name; } if (!ing.CanPurchase) { name = "**" + name; } m_SourceList.Add(new CNameIDForComboBox(ing.IngredientID, name)); } foreach (var recipe in m_DataSet.Recipe) { //if (recipe.IsFinalProductIDNull() || recipe.FinalProductID <= 0) // 該配方沒有最終產品,才列入 { string name = "配方:"; if (recipe.IsRecipeNameNull()) { name += recipe.RecipeID.ToString(); } else { name += recipe.RecipeName; } m_SourceList.Add(new CNameIDForComboBox(recipe.RecipeID + 10000, name)); } } sourceBindingSource.DataSource = m_SourceList; ShowProductColumn(false); }