Esempio n. 1
0
        private void UpdateDataBase(char pCntrlChar)
        {
            if (!Common.IsConnected)
            {
                MessageBox.Show("ネットワークに接続していません。");
                return;
            }
            Result result = new Result();
            DBService.Master master = new DBService.Master();

            if (cmbMaster.SelectedIndex != (int)MasterRole.Tax && 
                cmbMaster.SelectedIndex  != (int)MasterRole.Supplier)
            {
                master.Code = masterCode;
                master.Nm = txtName.Text;
                master.Del_Flg = chkMasterDel.IsChecked == true ? true : false;
            }
            
            switch (cmbMaster.SelectedIndex)
            {
                case (int)MasterRole.Category:
                    master.TableName ="ITEM_TYPE";
                    dbSf.UpdateMasterAsync(master, Common.staff.Nm, pcName, pCntrlChar);
                    DisplayCategory("0=0", "ITEM_TYPE");                    
                    break;
                case (int)MasterRole.Supplier:                    
                    DBService.Supplier supplier = new DBService.Supplier();
                    supplier.Code = masterCode;
                    supplier.Nm = txtName.Text;
                    supplier.Display_Order = Int16.Parse(txtOrder.Text);
                    supplier.Del_Flg = chkMasterDel.IsChecked == true ? true : false;
                    dbSp.UpdateSupplierAsync(supplier, Common.staff.Nm, pcName, pCntrlChar);
                    DisplaySupplier("0=0", "M_SUPPLIER");
                    break;
                case (int)MasterRole.Tax:
                    DBService.Tax tax = new DBService.Tax();
                    tax.Code = taxCode;
                    tax.Rate = Int32.Parse(txtRate.Text);
                    tax.StartDate =DateTime.Parse(dtpStartDate.Text);
                    tax.Del_Flg = chkTaxDel.IsChecked == true ? true : false;
                    dbTx.UpdateTaxAsync(tax, Common.staff.Nm, pcName, pCntrlChar);
                    DisplayTax("0=0");
                    break;
                case (int)MasterRole.Unit:
                    master.TableName ="M_UNIT";
                    dbUt.UpdateMasterAsync(master, Common.staff.Nm, pcName, pCntrlChar);
                    DisplayUnit("0=0", "M_UNIT");
                    break;
                case (int)MasterRole.PayCond:
                    master.TableName ="M_PAY_COND";
                    dbPC.UpdateMasterAsync(master, Common.staff.Nm, pcName, pCntrlChar);
                    DisplayPayCond("0=0", "M_PAY_COND");
                    break;
                case (int)MasterRole.Expiry:
                    master.TableName = "M_EXP_DATE";
                    dbEx.UpdateMasterAsync(master, Common.staff.Nm, pcName, pCntrlChar);
                    DisplayExpiryDate("0=0", "M_EXP_DATE");
                    break;
            }
            SetControlActive(true);
        }
Esempio n. 2
0
        private void SetData(DataGrid dg)
        {
            currentObj = null;
            tax =null;

            string caption = "マスター設定  → ";
            switch (dg.Name)
            {
                case "dgSupplier":
                    txtTitle.Text = caption + "仕入先";
                    cmbMaster.SelectedIndex = (int)MasterRole.Supplier;
                    cmbMaster.SelectedItem = "仕入先";
                    supplier = dgSupplier.SelectedItem as DBService.Supplier;
                    break;
                case "dgTax":
                    txtTitle.Text = caption + "消費税";
                    cmbMaster.SelectedIndex =(int)MasterRole.Tax;
                    tax = dgTax.SelectedItem as DBService.Tax;
                    break;
                case "dgUnit":
                    txtTitle.Text = caption + "単位";
                    cmbMaster.SelectedIndex = (int)MasterRole.Unit;
                    currentObj = dgUnit.SelectedItem as Master;
                    break;
                case "dgCategory":
                    txtTitle.Text = caption + "カテゴリ";
                    cmbMaster.SelectedIndex =(int)MasterRole.Category;
                    currentObj = dgCategory.SelectedItem as Master;
                    break;
                case "dgPayCond":
                    txtTitle.Text = caption + "支払条件";
                    cmbMaster.SelectedIndex =(int)MasterRole.PayCond;
                    currentObj = dgPayCond.SelectedItem as Master;
                    break;
                case "dgEX":
                    txtTitle.Text = caption + "見積有効期限";
                    cmbMaster.SelectedIndex =(int)MasterRole.Expiry;
                    currentObj = dgEX.SelectedItem as Master;
                    break;
            }

            if (currentObj != null && tax == null)
            {
                masterCode = currentObj.Code;
                txtName.Text = currentObj.Nm;
                chkMasterDel.IsChecked = currentObj.Del_Flg;
                this.MasterRoot.Visibility = System.Windows.Visibility.Visible;
                this.TaxRoot.Visibility = System.Windows.Visibility.Collapsed;
                Grid.SetRow(lblDelete1, 2);
                Grid.SetRow(chkMasterDel, 2);
                lblOrder.Visibility = System.Windows.Visibility.Collapsed;
                txtOrder.Visibility = System.Windows.Visibility.Collapsed;
                chkMasterDel.Visibility = System.Windows.Visibility.Visible;
                lblDelete1.Visibility = System.Windows.Visibility.Visible;
            }
            else if (currentObj == null && tax != null)
            {
                taxCode = tax.Code;
                dtpStartDate.Text = tax.StartDate.ToString();
                chkTaxDel.IsChecked = tax.Del_Flg;
                txtRate.Text = tax.Rate.ToString();
                this.MasterRoot.Visibility = System.Windows.Visibility.Collapsed ;
                this.TaxRoot.Visibility = System.Windows.Visibility.Visible;
            }
            else if (currentObj == null && supplier != null)
            {
                masterCode = supplier.Code;
                txtName.Text = supplier.Nm;
                chkMasterDel.IsChecked = supplier.Del_Flg;
                txtOrder.Text = supplier.Display_Order.ToString();
                this.MasterRoot.Visibility = System.Windows.Visibility.Visible;
                this.TaxRoot.Visibility = System.Windows.Visibility.Collapsed;
                Grid.SetRow(lblDelete1, 4);
                Grid.SetRow(chkMasterDel, 4);
                lblOrder.Visibility = System.Windows.Visibility.Visible;
                txtOrder.Visibility = System.Windows.Visibility.Visible;
                chkMasterDel.Visibility = System.Windows.Visibility.Visible;
                lblDelete1.Visibility = System.Windows.Visibility.Visible;
            }
        }