示例#1
0
    private void btnNextCustID_Click(object sender, System.EventArgs args)
    {
        DialogResult dialogResult = EpiMessageBox.Show("Are you sure you want to get next Cust ID?", "Cancel", MessageBoxButtons.YesNo);

        if ((dialogResult == DialogResult.Yes))
        {
            this.custAdapter = new CustomerAdapter(this.oTrans);
            this.custAdapter.BOConnect();

            DataRow currentCustomer = this.custDataView.CurrentDataRow;

            // Add Prefix
            string custID = formatNewID(currentCustomer["Name"].ToString());

            // Set Suffix
            int custSuffix = 0;             // 001

            // Iterate until suffix exists with prefix
            do
            {
                custSuffix++;
                try {
                    this.custAdapter.GetByCustID(custID + custSuffix.ToString("D3"), false);
                }catch (Exception e) {
                    break;
                }
            } while(custSuffix < 1000);

            // Set new custID
            string newCustID = custID + custSuffix.ToString("D3");
            //MessageBox.Show("New CustID: " + newCustID);

            currentCustomer["CustID"] = newCustID;

            /*et_newCustID = ((EpiTextBox)csm.GetNativeControlReference("3a3fffc1-6dee-4be0-b52e-7fc5f80e7b95"));
             * et_newCustID.Text = newCustID;*/
        }
    }
示例#2
0
    private void CustCnt_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
    {
        // ** Argument Properties and Uses **
        // args.Row["FieldName"]
        // args.Column, args.ProposedValue, args.Row
        // Add Event Handler Code
        EpiDataView edvCustomer = ((EpiDataView)(this.oTrans.EpiDataViews["Customer"]));

        System.Data.DataRow edvCustomerRow = edvCustomer.CurrentDataRow;
        string custID = edvCustomerRow["CustID"].ToString();


        CustomerAdapter custAdapter = new CustomerAdapter(this.oTrans);

        custAdapter.BOConnect();
        custAdapter.GetByCustID(custID, false);
        DataRow row = custAdapter.CustomerData.Customer[0];

        int primB = int.Parse(row["PrimBCon"].ToString());
        int primP = int.Parse(row["PrimPCon"].ToString());
        int primS = int.Parse(row["PrimSCon"].ToString());

        string leadType = "";
        bool   warning  = false;

        switch (args.Column.ColumnName)
        {
        case "PrimaryBilling":
            if (primB != 0 && args.ProposedValue.ToString() == "True")
            {
                warning  = true;
                leadType = "billing";
            }
            break;

        case "PrimaryPurchasing":
            if (primP != 0 && args.ProposedValue.ToString() == "True")
            {
                warning  = true;
                leadType = "purchasing";
            }
            break;

        case "PrimaryShipping":
            if (primS != 0 && args.ProposedValue.ToString() == "True")
            {
                warning  = true;
                leadType = "shipping";
            }
            break;
        }

        if (warning)
        {
            DialogResult dialogResult = EpiMessageBox.Show("There exists another contact for " + leadType + "\nContinue?", "Cancel", MessageBoxButtons.YesNo);
            if ((dialogResult == DialogResult.No))
            {
                oTrans.Undo();
            }
        }
    }
    private void btnCopyVehicles_Click(object sender, System.EventArgs args)
    {
        txtCopyPart = ((EpiTextBox)csm.GetNativeControlReference("d74c3905-a49e-42f4-a48d-e2a6a8b79379"));
        txtCopyRev  = ((EpiTextBox)csm.GetNativeControlReference("31cbeabb-4107-4626-ae5d-66897b75a8d8"));
        EpiDataView epiViewPartRev = ((EpiDataView)(this.oTrans.EpiDataViews["PartRev"]));
        DataRow     dataRowPartRev = epiViewPartRev.CurrentDataRow;
        string      partNum;
        string      revisionNum;

        if ((dataRowPartRev != null))
        {
            partNum     = dataRowPartRev["PartNum"].ToString();
            revisionNum = dataRowPartRev["RevisionNum"].ToString();


            if (txtCopyPart.Text == partNum && txtCopyRev.Text == revisionNum)
            {
                MessageBox.Show("Cannot copy from same Part Revision");
            }
            else if (txtCopyPart.Text == "" || txtCopyRev.Text == "")
            {
                MessageBox.Show("Choose a Part Revision");
            }
            else
            {
                DialogResult dialogResult = EpiMessageBox.Show("Are you sure you want to copy vehicles?", "Cancel", MessageBoxButtons.YesNo);
                if ((dialogResult == DialogResult.Yes))
                {
                    try {
                        // Set UD100Adapter

                        UD100Adapter ud100Adapter = new UD100Adapter(PartForm);
                        ud100Adapter.BOConnect();

                        Hashtable whereClauses = new Hashtable(1);
                        string    whereClause  = "ChildKey1 <> '' AND ChildKey2 <> ''";
                        whereClauses.Add("UD100A", whereClause);

                        SearchOptions searchOptions = SearchOptions.CreateRuntimeSearch(whereClauses, DataSetMode.RowsDataSet);
                        ud100Adapter.InvokeSearch(searchOptions);

                        // Delete all current PartRev's vehicles
                        DataRow[] deleteRows = ud100Adapter.UD100Data.UD100A.Select("ChildKey1 = \'" + partNum + "\' and ChildKey2 = \'" + revisionNum + "\'");
                        for (int i = 0; (i < deleteRows.Length); i++)
                        {
                            ud100Adapter.Delete(deleteRows[i]);
                        }

                        // Copy all selected PartRev's vehicles
                        DataRow[] copyRows = ud100Adapter.UD100Data.UD100A.Select("ChildKey1 = \'" + txtCopyPart.Text + "\' and ChildKey2 = \'" + txtCopyRev.Text + "\'");
                        for (int i = 0; (i < copyRows.Length); i++)
                        {
                            CreateChild(copyRows[i]["Brand_c"].ToString(), copyRows[i]["Model_c"].ToString(), copyRows[i]["Year_c"].ToString(), copyRows[i]["Length_c"].ToString(), copyRows[i]["Height_c"].ToString());
                        }
                        ud100Adapter.Update();
                        ud100Adapter.Dispose();
                        MessageBox.Show("Completed");
                    } catch (Exception e) {
                        MessageBox.Show(e.ToString());
                    }
                }
            }
        }
    }
    private void buttonCopy_Click(object sender, System.EventArgs args)
    {
        txtCopyPart      = ((EpiTextBox)csm.GetNativeControlReference("d74c3905-a49e-42f4-a48d-e2a6a8b79379"));
        txtCopyRev       = ((EpiTextBox)csm.GetNativeControlReference("31cbeabb-4107-4626-ae5d-66897b75a8d8"));
        this.partRevView = ((EpiDataView)(this.oTrans.EpiDataViews["PartRev"]));
        DataRow dataRowPartRev = this.partRevView.CurrentDataRow;
        string  partNum;
        string  revisionNum;

        if ((dataRowPartRev != null))
        {
            partNum     = dataRowPartRev["PartNum"].ToString();
            revisionNum = dataRowPartRev["RevisionNum"].ToString();

            if (txtCopyPart.Text == partNum && txtCopyRev.Text == revisionNum)
            {
                MessageBox.Show("Cannot copy from same Part Revision");
            }
            else if (txtCopyPart.Text == "" || txtCopyRev.Text == "")
            {
                MessageBox.Show("Choose a Part Revision");
            }
            else
            {
                DialogResult dialogResult = EpiMessageBox.Show("Are you sure you want to copy attributes?", "Cancel", MessageBoxButtons.YesNo);
                if ((dialogResult == DialogResult.Yes))
                {
                    try {
                        this.partRevAdapter = new PartRevSearchAdapter(this.oTrans);
                        this.partRevAdapter.BOConnect();
                        this.partRevAdapter.GetByID(txtCopyPart.Text, txtCopyRev.Text, "");
                        DataRow dataRow = this.partRevAdapter.PartRevSearchData.PartRev.Rows[0];

                        if (this.partRevAdapter.PartRevSearchData.PartRev.Count > 0)
                        {
                            dataRowPartRev["Height_c"] = dataRow["Height_c"];
                            dataRowPartRev["Width_c"]  = dataRow["Width_c"];
                            dataRowPartRev["Depth_c"]  = dataRow["Depth_c"];

                            dataRowPartRev["Weight_c"]          = dataRow["Weight_c"];
                            dataRowPartRev["PrimaryMaterial_c"] = dataRow["PrimaryMaterial_c"];
                            dataRowPartRev["Color_c"]           = dataRow["Color_c"];
                            dataRowPartRev["WeightCap_c"]       = dataRow["WeightCap_c"];

                            dataRowPartRev["InstallTime_c"]   = dataRow["InstallTime_c"];
                            dataRowPartRev["ReqInstallKit_c"] = dataRow["ReqInstallKit_c"];

                            dataRowPartRev["UsedWith_c"]             = dataRow["UsedWith_c"];
                            dataRowPartRev["MaxLadderLength_c"]      = dataRow["MaxLadderLength_c"];
                            dataRowPartRev["PartitionOffset_c"]      = dataRow["PartitionOffset_c"];
                            dataRowPartRev["PartitionDoorOpening_c"] = dataRow["PartitionDoorOpening_c"];
                            dataRowPartRev["NumShelves_c"]           = dataRow["NumShelves_c"];
                            dataRowPartRev["OpenShelfSpace_c"]       = dataRow["OpenShelfSpace_c"];

                            dataRowPartRev["NumSmallBins_c"]  = dataRow["NumSmallBins_c"];
                            dataRowPartRev["NumMediumBins_c"] = dataRow["NumMediumBins_c"];
                            dataRowPartRev["NumLargeBins_c"]  = dataRow["NumLargeBins_c"];
                            dataRowPartRev["NumBottles_c"]    = dataRow["NumBottles_c"];
                            dataRowPartRev["NumDividers_c"]   = dataRow["NumDividers_c"];
                            dataRowPartRev["QtyBoxes_c"]      = dataRow["QtyBoxes_c"];

                            MessageBox.Show("Completed");
                            this.partRevAdapter.Dispose();
                        }
                    } catch (Exception e) {
                        MessageBox.Show(e.ToString());
                    }
                }
            }
        }
    }