Пример #1
0
        public static void SaveSoDocx(So so, List <SoItemsContentAndState> soitemsList)
        {
            document = DocX.Load(@"SoDocx.dll");
            Formatting format = new Formatting();

            format.FontFamily = new System.Drawing.FontFamily("Arial");
            format.Size       = 9;
            Table soTable = document.Tables[0];

            soTable.Rows[0].Cells[1].Paragraphs[0].InsertText(so.customerName, false, format);
            soTable.Rows[0].Cells[3].Paragraphs[0].InsertText(Tool.Get6DigitalNumberAccordingToId(so.soId), false, format);
            soTable.Rows[1].Cells[3].Paragraphs[0].InsertText((so.orderDate.Year + "-" + so.orderDate.Month + "-" + so.orderDate.Day).ToString(), false, format);
            soTable.Rows[2].Cells[3].Paragraphs[0].InsertText(so.paymentTerm, false, format);
            soTable.Rows[3].Cells[1].Paragraphs[0].InsertText(so.contact, false, format);
            soTable.Rows[3].Cells[3].Paragraphs[0].InsertText(so.freightTerm, false, format);
            soTable.Rows[4].Cells[1].Paragraphs[0].InsertText(AllAccountInfo.GetNameAccordingToId(UserInfo.UserId), false, format);

            custvendorinfo custven = CustVenInfoManager.GetUniqueCustVenInfo(0, so.customerName, UserInfo.UserId);

            if (custven != null)
            {
                soTable.Rows[1].Cells[1].Paragraphs[0].InsertText(custven.phone1, false, format);
                soTable.Rows[2].Cells[1].Paragraphs[0].InsertText(custven.fax, false, format);
            }

            Table itemTable = document.Tables[1];

            if (soitemsList.Count > 2)
            {
                Row sampleRow = itemTable.Rows[2];
                for (int i = 0; i < soitemsList.Count - 2; i++)
                {
                    itemTable.InsertRow(sampleRow, 2);
                }
            }
            float totalAmount = 0;

            for (int i = 0; i < soitemsList.Count; i++)
            {
                itemTable.Rows[i + 2].Cells[0].Paragraphs[0].InsertText((i + 1).ToString(), false, format);
                itemTable.Rows[i + 2].Cells[1].Paragraphs[0].InsertText(soitemsList[i].soitem.partNo, false, format);
                itemTable.Rows[i + 2].Cells[2].Paragraphs[0].InsertText(soitemsList[i].soitem.mfg, false, format);
                itemTable.Rows[i + 2].Cells[3].Paragraphs[0].InsertText(soitemsList[i].soitem.qty.ToString(), false, format);
                // itemTable.Rows[i+2].Cells[4].InsertParagraph(soitemsList[i].soitem.
                if (soitemsList[i].soitem.currencyType == (int)Currency.USD)
                {
                    itemTable.Rows[i + 2].Cells[5].Paragraphs[0].InsertText(soitemsList[i].soitem.unitPrice.ToString(), false, format);
                    itemTable.Rows[i + 2].Cells[6].Paragraphs[0].InsertText((soitemsList[i].soitem.unitPrice * soitemsList[i].soitem.qty).ToString(), false, format);
                }
                else
                {
                    itemTable.Rows[i + 2].Cells[5].Paragraphs[0].InsertText(soitemsList[i].soitem.unitPrice.ToString() + Enum.GetName(typeof(Currency), soitemsList[i].soitem.currencyType), false, format);
                    itemTable.Rows[i + 2].Cells[6].Paragraphs[0].InsertText((soitemsList[i].soitem.unitPrice * soitemsList[i].soitem.qty).ToString() + Enum.GetName(typeof(Currency), soitemsList[i].soitem.currencyType), false, format);
                }
                totalAmount += soitemsList[i].soitem.unitPrice * soitemsList[i].soitem.qty;
            }
            itemTable.Rows[itemTable.Rows.Count - 1].Cells[4].Paragraphs[0].InsertText(totalAmount.ToString(), false, format);
            WriteToFile();
        }
        public void FillTheInfo(custvendorinfo cvInfo)
        {
            tbName.Text = cvInfo.cvname;

            if (string.IsNullOrWhiteSpace(cvInfo.cvnumber))
            {
                string sixNumber = Tool.Get6DigitalNumberAccordingToId(cvInfo.cvId);
                tbCompnayNumber.Text = (cvInfo.cvtype == 0 ? "C" : "V") + sixNumber;
            }
            else
            {
                tbCompnayNumber.Text = cvInfo.cvnumber;
            }

            tbPaymentTerm.Text  = cvInfo.paymentTerm;
            tbShippingTerm.Text = cvInfo.shippingTerm;
            tbBillto.Text       = cvInfo.billTo;
            //get the shipToList
            shipToList.AddRange(CustVenInfoManager.GetShipTo(cvInfo.cvId));

            if (shipToList.Count == 1)
            {
                ShipTo1.Text = shipToList[0].shipTo;
            }
            else if (shipToList.Count > 1)
            {
                ShipTo1.Text = shipToList[0].shipTo;


                for (int i = 1; i < shipToList.Count; i++)
                {
                    System.Windows.Forms.TextBox ShipTo = new TextBox();

                    ShipTo.Dock      = System.Windows.Forms.DockStyle.Fill;
                    ShipTo.Location  = new System.Drawing.Point(3, 3);
                    ShipTo.Multiline = true;
                    ShipTo.Name      = "ShipTo";
                    ShipTo.Size      = new System.Drawing.Size(570, 76);
                    ShipTo.TabIndex  = 0;
                    ShipTo.Text      = shipToList[i].shipTo;

                    System.Windows.Forms.TabPage tabPage = new TabPage();

                    tabPage.Controls.Add(ShipTo);
                    tabPage.Location = new System.Drawing.Point(4, 25);
                    tabPage.Name     = "tabPage1";
                    tabPage.Padding  = new System.Windows.Forms.Padding(3);
                    tabPage.Size     = new System.Drawing.Size(576, 82);
                    tabPage.TabIndex = i;
                    tabPage.Text     = "Ship To " + (i + 1).ToString();
                    tabPage.UseVisualStyleBackColor = true;
                    tabControl1.TabPages.Add(tabPage);
                }
            }
        }
Пример #3
0
        private void CustomerAutoComplete()
        {
            List <string> customerNames = CustVenInfoManager.GetAllCustomerVendorNameICanSee(0, UserInfo.UserId);

            tbCustomer.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            tbCustomer.AutoCompleteSource = AutoCompleteSource.CustomSource;

            AutoCompleteStringCollection autoSource = new AutoCompleteStringCollection();

            foreach (string customerName in customerNames)
            {
                autoSource.Add(customerName);
            }
            tbCustomer.AutoCompleteCustomSource = autoSource;
        }
        protected override void FillTheDataGrid()
        {
            custVenInfoList.Clear();
            if (tscbAllOrMine.SelectedIndex == 0)
            {
                custVenInfoList.AddRange(CustVendorManager.CustVenInfoManager.GetCVIcanSee(cvtype, UserInfo.UserId, filterColumn, tstbFilterString.Text.Trim()));
            }
            else if (tscbAllOrMine.SelectedIndex == 1)
            {
                custVenInfoList.AddRange(CustVenInfoManager.GetMyCustomerOrVendors(cvtype, UserInfo.UserId, filterColumn, tstbFilterString.Text.Trim()));
            }
            else
            {
            }
            int i = 0;

            foreach (custvendorinfo cvInfo in custVenInfoList)
            {
                dataGridView1.Rows.Add(i, cvInfo.cvname, cvInfo.contact1, cvInfo.phone1, cvInfo.cellphone, cvInfo.fax, cvInfo.email1,
                                       AllAccountInfo.GetNameAccordingToId(cvInfo.ownerName));
                i++;
            }
        }
Пример #5
0
        private void tbCustomer_Leave(object sender, EventArgs e)
        {
            //自动填充contact,phone,fax
            Dictionary <string, string> contactInfo = CustVenInfoManager.GetContactInfo(0, UserInfo.UserId, tbCustomer.Text.Trim());
            //contact
            AutoCompleteStringCollection contactSource = new AutoCompleteStringCollection();

            if (contactInfo.Keys.Contains("contact1"))
            {
                tbContact.Text = contactInfo["contact1"];
                contactSource.Add(contactInfo["contact1"]);
            }
            if (contactInfo.Keys.Contains("contact2"))
            {
                contactSource.Add(contactInfo["contact2"]);
            }
            tbContact.AutoCompleteMode         = AutoCompleteMode.SuggestAppend;
            tbContact.AutoCompleteSource       = AutoCompleteSource.CustomSource;
            tbContact.AutoCompleteCustomSource = contactSource;
            //phone
            AutoCompleteStringCollection phoneSource = new AutoCompleteStringCollection();

            if (contactInfo.Keys.Contains("phone1"))
            {
                tbPhone.Text = contactInfo["phone1"];
                phoneSource.Add(contactInfo["phone1"]);
            }

            if (contactInfo.Keys.Contains("phone2"))
            {
                phoneSource.Add(contactInfo["phone2"]);
            }
            if (contactInfo.Keys.Contains("cellphone"))
            {
                phoneSource.Add(contactInfo["cellphone"]);
            }
            tbPhone.AutoCompleteMode         = AutoCompleteMode.SuggestAppend;
            tbPhone.AutoCompleteSource       = AutoCompleteSource.CustomSource;
            tbPhone.AutoCompleteCustomSource = phoneSource;

            AutoCompleteStringCollection faxSource = new AutoCompleteStringCollection();

            if (contactInfo.Keys.Contains("fax"))
            {
                tbFax.Text = contactInfo["fax"];
                faxSource.Add(contactInfo["fax"]);
            }

            tbFax.AutoCompleteMode         = AutoCompleteMode.SuggestAppend;
            tbFax.AutoCompleteSource       = AutoCompleteSource.CustomSource;
            tbFax.AutoCompleteCustomSource = faxSource;

            AutoCompleteStringCollection emailSource = new AutoCompleteStringCollection();

            if (contactInfo.Keys.Contains("email1"))
            {
                tbEmail.Text = contactInfo["email1"];
                emailSource.Add(contactInfo["email1"]);
            }
            if (contactInfo.Keys.Contains("email2"))
            {
                emailSource.Add(contactInfo["email2"]);
            }
            tbEmail.AutoCompleteMode         = AutoCompleteMode.SuggestAppend;
            tbEmail.AutoCompleteSource       = AutoCompleteSource.CustomSource;
            tbEmail.AutoCompleteCustomSource = emailSource;
        }