/// <summary> /// Добавляет в дерево строку ля указанной компании /// </summary> /// <param name="objCompany">компания</param> private void AddCompany(CCompany objCompany) { try { if (objCompany == null) { return; } System.Boolean bCompanyExists = false; foreach (DevExpress.XtraTreeList.Nodes.TreeListNode objNode in treeList.Nodes) { if (objNode.Tag == null) { continue; } if (((CCreditLimit)objNode.Tag).Company.ID.CompareTo(objCompany.ID) == 0) { bCompanyExists = true; break; } } if (bCompanyExists == false) { CCreditLimit objNewCreditLimit = new CCreditLimit(System.Guid.Empty, m_objSelectedCustomer, objCompany, (CCurrency)cboxCurrency.SelectedItem, 0, 0, 0, 0); treeList.AppendNode(new object[] { objNewCreditLimit.Company.Abbr, objNewCreditLimit.ApprovedCurrencyValue, objNewCreditLimit.ApprovedDays, objNewCreditLimit.CurrencyValue, objNewCreditLimit.Days }, null).Tag = objNewCreditLimit; System.Int32 iRemoveIndx = -1; for (System.Int32 i = 0; i < listBoxCompany.Items.Count; i++) { if (((CCompany)listBoxCompany.GetItemValue(i)).ID.CompareTo(objCompany.ID) == 0) { iRemoveIndx = i; break; } } if (iRemoveIndx >= 0) { listBoxCompany.Items.RemoveAt(iRemoveIndx); } SetPropertiesModified(true); } } catch (System.Exception f) { SendMessageToLog("Ошибка редактирования кредитного лимита клиента. Текст ошибки: " + f.Message); } finally { EnableCompanyBtns(); } return; }
/// <summary> /// Сохраняет изменения в базе данных /// </summary> /// <returns>true - удачное завершение операции;false - ошибка</returns> private System.Boolean bSaveChanges() { System.Boolean bRet = false; List <CCreditLimit> objCreditLimitListForSave = new List <CCreditLimit>(); try { CCreditLimit objCreditLimit = null; foreach (DevExpress.XtraTreeList.Nodes.TreeListNode objNode in treeList.Nodes) { if (objNode.Tag == null) { continue; } objCreditLimit = (CCreditLimit)objNode.Tag; objCreditLimit.ApprovedCurrencyValue = System.Convert.ToDouble(objNode.GetValue(colMoneyApprov)); objCreditLimit.CurrencyValue = System.Convert.ToDouble(objNode.GetValue(colMoney)); objCreditLimit.ApprovedDays = System.Convert.ToInt32(objNode.GetValue(colDayApprov)); objCreditLimit.Days = System.Convert.ToInt32(objNode.GetValue(colDay)); objCreditLimitListForSave.Add(objCreditLimit); } if (objCreditLimitListForSave != null) { System.String strErr = ""; bRet = CCreditLimit.SaveCreditLimitList(m_objProfile, null, objCreditLimitListForSave, m_objSelectedCustomer, (CCurrency)cboxCurrency.SelectedItem, ref strErr); if (bRet == false) { SendMessageToLog(strErr); } else { m_objSelectedCustomer.CreditLimitList = objCreditLimitListForSave; } } objCreditLimitListForSave = null; } catch (System.Exception f) { SendMessageToLog("Ошибка сохранения изменений в кредитном лимите клиента. Текст ошибки: " + f.Message); } finally { } return(bRet); }
/// <summary> /// добавляет в дерево все компании /// </summary> private void AddAllCompany() { try { this.tableLayoutPanelBgrnd.SuspendLayout(); this.tableLayoutPaneltree.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.treeList)).BeginInit(); System.Boolean bCompanyExists = false; for (System.Int32 i = 0; i < listBoxCompany.Items.Count; i++) { foreach (DevExpress.XtraTreeList.Nodes.TreeListNode objNode in treeList.Nodes) { if (objNode.Tag == null) { continue; } if (((CCreditLimit)objNode.Tag).Company.ID.CompareTo(((CCompany)listBoxCompany.GetItemValue(i)).ID) == 0) { bCompanyExists = true; break; } } if (bCompanyExists == false) { CCreditLimit objNewCreditLimit = new CCreditLimit(System.Guid.Empty, m_objSelectedCustomer, ((CCompany)listBoxCompany.GetItemValue(i)), (CCurrency)cboxCurrency.SelectedItem, 0, 0, 0, 0); treeList.AppendNode(new object[] { objNewCreditLimit.Company.Abbr, objNewCreditLimit.ApprovedCurrencyValue, objNewCreditLimit.CurrencyValue, objNewCreditLimit.ApprovedDays, objNewCreditLimit.Days }, null).Tag = objNewCreditLimit; } } listBoxCompany.Items.Clear(); SetPropertiesModified(true); this.tableLayoutPanelBgrnd.ResumeLayout(false); this.tableLayoutPaneltree.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.treeList)).EndInit(); } catch (System.Exception f) { SendMessageToLog("Ошибка редактирования кредитного лимита клиента. Текст ошибки: " + f.Message); } finally { EnableCompanyBtns(); } return; }
/// <summary> /// Загружает значение категории клиента в дерево /// </summary> /// <param name="objCustomer"></param> public void LoadCustomerLimit(CCustomer objCustomer) { m_bDisableEvents = true; if (objCustomer == null) { return; } try { m_objSelectedCustomer = objCustomer; lblCustomerIfo.Text = objCustomer.FullName; dtBeginDate.DateTime = System.DateTime.Today; dtEndDate.DateTime = System.DateTime.Today; listBoxCompany.Items.Clear(); List <CCompany> objCompanyList = CCompany.GetCompanyListFreeBlackList(m_objSelectedCustomer, m_objProfile, null); if (objCompanyList != null) { foreach (CCompany objCompany in objCompanyList) { listBoxCompany.Items.Add(objCompany); } } objCompanyList = null; m_objCreditLimitList = CCreditLimit.GetCreditLimitList(m_objProfile, null, m_objSelectedCustomer); if (cboxCurrency.Properties.Items.Count > 0) { if ((m_objCreditLimitList != null) && (m_objCreditLimitList.Count > 0)) { foreach (CCurrency objItem in cboxCurrency.Properties.Items) { if (objItem.ID.CompareTo(m_objCreditLimitList[0].Currency.ID) == 0) { cboxCurrency.SelectedItem = objItem; break; } } } else { cboxCurrency.SelectedItem = cboxCurrency.Properties.Items[0]; } LoadCustomerLimitByCurrency((CCurrency)cboxCurrency.SelectedItem); } System.Boolean bBlackList = CCreditLimit.IsCustomerInBlackList(m_objProfile, null, m_objSelectedCustomer); tableLayoutPanelBgrnd.RowStyles[1].Height = (bBlackList ? iPanelInfoHeight : iPanelInfoMinHeight); panelControlInfo.Visible = bBlackList; } catch (System.Exception f) { SendMessageToLog("Ошибка редактирования кредитного лимита клиента. Текст ошибки: " + f.Message); } finally { m_bDisableEvents = false; } return; }