Example #1
0
        /// <summary>
        /// Филтриран списък отстъки
        /// </summary>
        public List <ListItemModel> GetFilterList(string term)
        {
            List <ListItemModel> model = new List <ListItemModel>();
            string filter      = ((term == "*") ? "'%'" : String.Format("'%{0}%'", term));
            string commandText =
                @"SELECT TOP 20 d.ID
       , d.D_NAME
 FROM DISCOUNT d
 WHERE d.D_NAME LIKE " + filter + @"
 ORDER BY d.D_NAME ";

            using (DataTable dtDiscounts = FillDataTable(commandText))
            {
                foreach (DataRow drDiscount in dtDiscounts.Rows)
                {
                    model.Add(new ListItemModel()
                    {
                        id     = TryParse.ToString(drDiscount["ID"]),
                        label  = TryParse.ToString(drDiscount["D_NAME"]),
                        abbrev = ""
                    });
                }
            }
            return(model);
        }
Example #2
0
        public HydraAppsModel GetApplications()
        {
            HydraAppsModel model = new HydraAppsModel();

            using (SQLiteConnection connection = this.OpenConnection())
            {
                string commandText =
                    @"SELECT ap.uid
       , ap.app_name
       , ap.app_url
       , ap.description
       , dv.id AS developer_id
       , dv.dev_name AS developer_name
  FROM application ap 
  LEFT JOIN developer dv ON dv.id = ap.developer_id 
  ORDER BY ap.app_name ";
                using (DataTable dtApplications = this.Fill(commandText))
                {
                    foreach (DataRow app in dtApplications.Rows)
                    {
                        model.Add(new HydraAppModel()
                        {
                            UId           = TryParse.ToGuid(app["uid"]),
                            Name          = TryParse.ToString(app["app_name"]),
                            DeveloperId   = TryParse.ToInt32(app["developer_id"]),
                            DeveloperName = TryParse.ToString(app["developer_name"]),
                            AppUrl        = TryParse.ToString(app["app_url"]),
                            Description   = TryParse.ToString(app["description"])
                        });
                    }
                }
            }
            return(model);
        }
Example #3
0
        public List <CCardModel> GetCards()
        {
            List <CCardModel> model       = new List <CCardModel>();
            string            commandText =
                @"SELECT cc.ID
       , cc.C_NUMBER
       , cc.VALID_FROM_DATE
       , cc.VALID_TO_DATE
       , cc.IS_BLOCKED
       , cc.CONTRACTOR_ID
 FROM C_CARD cc
 ORDER BY cc.C_NUMBER ";

            using (DataTable dtCCards = FillDataTable(commandText))
            {
                foreach (DataRow drCCard in dtCCards.Rows)
                {
                    model.Add(new CCardModel()
                    {
                        CardId       = TryParse.ToInt32(drCCard["ID"]),
                        CNumber      = TryParse.ToString(drCCard["C_NUMBER"]),
                        ValidFrom    = TryParse.ToDateTime(drCCard["VALID_FROM_DATE"]),
                        ValidTo      = TryParse.ToDateTime(drCCard["VALID_TO_DATE"]),
                        IsBlocked    = (TryParse.ToInt32(drCCard["IS_BLOCKED"]) == 1),
                        ContractorId = TryParse.ToInt32(drCCard["CONTRACTOR_ID"])
                    });
                }
            }
            return(model);
        }
Example #4
0
        /// <summary>
        /// Списък контрагенти
        /// </summary>
        public List <ListItemModel> GetList(string term)
        {
            List <ListItemModel> model = new List <ListItemModel>();
            string termValue           = (String.IsNullOrWhiteSpace(term) || term.Equals("*")) ? "" : term;

            string commandText =
                @"SELECT TOP 15 c.ID, c.C_NAME
 FROM CONTRACTOR c
 WHERE c.C_NAME LIKE N'%" + termValue + @"%'
 ORDER BY c.C_NAME ";

            using (DataTable dtItems = FillDataTable(commandText))
            {
                foreach (DataRow drItem in dtItems.Rows)
                {
                    model.Add(new ListItemModel()
                    {
                        id     = TryParse.ToString(drItem["ID"]),
                        label  = TryParse.ToString(drItem["C_NAME"]),
                        abbrev = ""
                    });
                }
            }
            return(model);
        }
Example #5
0
        public ContractorModel GetContractor(int id)
        {
            ContractorModel model       = null;
            string          commandText =
                @"SELECT cnt.ID AS CONTRACTOR_ID
       , cnt.CONTRACTOR_TYPE_ID
       , cnt.C_NAME
       , cnt.ID_CONTRACTOR
       , cnt.S_TOWN_ID
       , cnt.C_ADDRESS
       , ISNULL(c_cmp.ACCOUNTABLE_PERSON, '') AS ACCOUNTABLE_PERSON
 FROM CONTRACTOR cnt
 LEFT JOIN CONTRACTOR_COMPANY c_cmp ON c_cmp.CONTRACTOR_ID = cnt.ID
 WHERE cnt.ID = " + SQLInt(id);

            using (DataTable dtContractors = FillDataTable(commandText))
            {
                if (dtContractors.Rows.Count > 0)
                {
                    DataRow drContractor = dtContractors.Rows[0];
                    model = new ContractorModel()
                    {
                        ContractorId      = TryParse.ToInt32(drContractor["CONTRACTOR_ID"]),
                        Name              = TryParse.ToString(drContractor["C_NAME"]),
                        ContractorTypeId  = TryParse.ToInt32(drContractor["CONTRACTOR_TYPE_ID"]),
                        IdContractor      = TryParse.ToString(drContractor["ID_CONTRACTOR"]),
                        TownId            = TryParse.ToInt32(drContractor["S_TOWN_ID"]),
                        Address           = TryParse.ToString(drContractor["C_ADDRESS"]),
                        AccountablePerson = TryParse.ToString(drContractor["ACCOUNTABLE_PERSON"])
                    };
                }
            }
            return(model);
        }
Example #6
0
        public List <ContractorModel> GetContractors()
        {
            List <ContractorModel> model = new List <ContractorModel>();
            string commandText           =
                @"SELECT cnt.ID AS CONTRACTOR_ID
       , cnt.CONTRACTOR_TYPE_ID
       , cnt.C_NAME
       , cnt.ID_CONTRACTOR
       , cnt.S_TOWN_ID
       , cnt.C_ADDRESS
       , ISNULL(c_cmp.ACCOUNTABLE_PERSON, '') AS ACCOUNTABLE_PERSON
 FROM CONTRACTOR cnt
 LEFT JOIN CONTRACTOR_COMPANY c_cmp ON c_cmp.CONTRACTOR_ID = cnt.ID
 ORDER BY cnt.C_NAME ";

            using (DataTable dtContractors = FillDataTable(commandText))
            {
                foreach (DataRow drContractor in dtContractors.Rows)
                {
                    model.Add(new ContractorModel()
                    {
                        ContractorId      = TryParse.ToInt32(drContractor["CONTRACTOR_ID"]),
                        Name              = TryParse.ToString(drContractor["C_NAME"]),
                        ContractorTypeId  = TryParse.ToInt32(drContractor["CONTRACTOR_TYPE_ID"]),
                        IdContractor      = TryParse.ToString(drContractor["ID_CONTRACTOR"]),
                        TownId            = TryParse.ToInt32(drContractor["S_TOWN_ID"]),
                        Address           = TryParse.ToString(drContractor["C_ADDRESS"]),
                        AccountablePerson = TryParse.ToString(drContractor["ACCOUNTABLE_PERSON"])
                    });
                }
            }
            return(model);
        }
Example #7
0
        public DiscountGroupModel GetDiscountGroup(int id)
        {
            DiscountGroupModel model       = null;
            string             commandText =
                @"SELECT dg.ID AS DISCOUNT_GROUP_ID
       , dg.DG_NAME
       , (SELECT ',' + cast(sgi.DISCOUNT_ID AS nvarchar(MAX)) AS [text()]
          FROM DISCOUNT_GROUP_ITEM sgi
          WHERE sgi.DISCOUNT_GROUP_ID = dg.ID
          For XML PATH ('')
         ) + ',' AS DISCOUNT_LIST
 FROM DISCOUNT_GROUP dg
 WHERE dg.ID = " + SQLInt(id);

            using (DataTable dtDiscounts = FillDataTable(commandText))
            {
                if (dtDiscounts.Rows.Count > 0)
                {
                    DataRow drDiscount = dtDiscounts.Rows[0];
                    model = new DiscountGroupModel()
                    {
                        DiscountGroupId = TryParse.ToInt32(drDiscount["DISCOUNT_GROUP_ID"]),
                        Name            = TryParse.ToString(drDiscount["DG_NAME"]),
                        DiscountList    = TryParse.ToString(drDiscount["DISCOUNT_LIST"])
                    };
                }
            }
            return(model);
        }
Example #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="value"></param>
 /// <param name="sb"></param>
 protected override void BuildParameterName(object value, ref StringBuilder sb)
 {
     if (this.NeedParams && this.Provider != null)
     {
         ParamInfo p = this.Provider.BuildParamInfo(false, this._ParamList, value, this._CurrentMemberInfo, ref this._paramIndex);
         this._ParamList.Add(p);
         this._paramIndex++;
         sb.Append(this.Provider.BuildSpecialName(p.Name));
     }
     else
     {
         if (value.GetType().IsStringType())
         {
             string text = TryParse.ToString(value);
             sb.Append("'");
             sb.Append(text);
             sb.Append("'");
         }
         else
         {
             string text = TryParse.ToString(value);
             sb.Append(text);
         }
     }
 }
Example #9
0
        /// <summary>
        /// Списък групи отстъки
        /// </summary>
        public List <ListItemModel> GetGroupList()
        {
            List <ListItemModel> model = new List <ListItemModel>();

            model.Add(new ListItemModel()
            {
                id     = "-1",
                label  = "Без отстъпка",
                abbrev = ""
            });
            string commandText =
                @"SELECT dg.ID, dg.DG_NAME
 FROM DISCOUNT_GROUP dg
 ORDER BY dg.DG_NAME ";

            using (DataTable dtDiscounts = FillDataTable(commandText))
            {
                foreach (DataRow drDiscount in dtDiscounts.Rows)
                {
                    model.Add(new ListItemModel()
                    {
                        id     = TryParse.ToString(drDiscount["ID"]),
                        label  = TryParse.ToString(drDiscount["DG_NAME"]),
                        abbrev = ""
                    });
                }
            }
            return(model);
        }
Example #10
0
        public DiscountModel GetDiscount(int id)
        {
            DiscountModel model       = null;
            string        commandText =
                @"SELECT d.ID AS DISCOUNT_ID
       , d.D_NAME
       , d.VALID_FROM_DATE
       , d.VALID_TO_DATE
       , d.DISCOUNT_KIND_ID
       , dk.DK_NAME
       , d.D_VALUE
 FROM DISCOUNT d
 LEFT JOIN DISCOUNT_KIND dk ON dk.ID = d.DISCOUNT_KIND_ID
 WHERE d.ID = " + SQLInt(id);

            using (DataTable dtDiscounts = FillDataTable(commandText))
            {
                if (dtDiscounts.Rows.Count > 0)
                {
                    DataRow drDiscount = dtDiscounts.Rows[0];
                    model = new DiscountModel()
                    {
                        DiscountId       = TryParse.ToInt32(drDiscount["DISCOUNT_ID"]),
                        Name             = TryParse.ToString(drDiscount["D_NAME"]),
                        DiscountKindId   = TryParse.ToInt32(drDiscount["DISCOUNT_KIND_ID"]),
                        DiscountKindName = TryParse.ToString(drDiscount["DK_NAME"]),
                        ValidFrom        = TryParse.ToDateTime(drDiscount["VALID_FROM_DATE"]),
                        ValidTo          = TryParse.ToDateTime(drDiscount["VALID_TO_DATE"]),
                        Value            = TryParse.ToDecimal(drDiscount["D_VALUE"]),
                    };
                }
            }
            return(model);
        }
Example #11
0
        public List <DiscountModel> GetDiscounts()
        {
            List <DiscountModel> model = new List <DiscountModel>();
            string commandText         =
                @"SELECT d.ID AS DISCOUNT_ID
       , d.D_NAME
       , d.VALID_FROM_DATE
       , d.VALID_TO_DATE
       , d.DISCOUNT_KIND_ID
       , dk.DK_NAME
       , d.D_VALUE
 FROM DISCOUNT d
 LEFT JOIN DISCOUNT_KIND dk ON dk.ID = d.DISCOUNT_KIND_ID
 ORDER BY d.D_NAME ";

            using (DataTable dtDiscounts = FillDataTable(commandText))
            {
                foreach (DataRow drDiscount in dtDiscounts.Rows)
                {
                    model.Add(new DiscountModel()
                    {
                        DiscountId       = TryParse.ToInt32(drDiscount["DISCOUNT_ID"]),
                        Name             = TryParse.ToString(drDiscount["D_NAME"]),
                        DiscountKindId   = TryParse.ToInt32(drDiscount["DISCOUNT_KIND_ID"]),
                        DiscountKindName = TryParse.ToString(drDiscount["DK_NAME"]),
                        ValidFrom        = TryParse.ToDateTime(drDiscount["VALID_FROM_DATE"]),
                        ValidTo          = TryParse.ToDateTime(drDiscount["VALID_TO_DATE"]),
                        Value            = TryParse.ToDecimal(drDiscount["D_VALUE"]),
                    });
                }
            }
            return(model);
        }
Example #12
0
        /// <summary>
        /// Списък отстъки
        /// </summary>
        public List <ListItemModel> GetList(string discountList)
        {
            List <ListItemModel> model = new List <ListItemModel>();
            string sqlDiscountList     = discountList.Trim(',');

            if (String.IsNullOrWhiteSpace(sqlDiscountList))
            {
                return(model);
            }

            string commandText =
                @"SELECT d.ID, d.D_NAME
 FROM DISCOUNT d
 WHERE d.ID IN (" + sqlDiscountList + @")
 ORDER BY d.D_NAME ";

            using (DataTable dtDiscounts = FillDataTable(commandText))
            {
                foreach (DataRow drDiscount in dtDiscounts.Rows)
                {
                    model.Add(new ListItemModel()
                    {
                        id     = TryParse.ToString(drDiscount["ID"]),
                        label  = TryParse.ToString(drDiscount["D_NAME"]),
                        abbrev = ""
                    });
                }
            }
            return(model);
        }
Example #13
0
 protected override bool ProcessDataGridViewKey(KeyEventArgs e)
 {
     if (e.KeyData == Keys.Down)
     {
         if (this.SelectedRows.Count > 0 && this.SelectedRows[0].Index == this.RowCount - 1)
         {
             this.RowCount++;
             if (OnRowDefaultValue != null)
             {
                 OnRowDefaultValue(this, new DefaultValueEventArgs(this.RowCount - 1));
             }
         }
     }
     else if (e.Control && e.KeyCode == Keys.Delete)
     {
         if (ForzenColumn != null && this.SelectedRows.Count > 0)
         {
             if (!string.IsNullOrEmpty(TryParse.ToString(this[ForzenColumn.Index, SelectedRows[0].Index].Value)))
             {
                 if (MessageBoxHelper.ShowQuestion("确定删除当前行吗?") == DialogResult.OK)
                 {
                     this.Rows.RemoveAt(this.SelectedRows[0].Index);
                     this.RowCount++;
                 }
             }
         }
     }
     return(base.ProcessDataGridViewKey(e));
 }
Example #14
0
 private void SetEntryValue()
 {
     if (cbDataEditor.SelectedValue == null)
     {
         return;
     }
     this.TextValue = TryParse.ToString(cbDataEditor.SelectedValue);
 }
Example #15
0
 public void Init(object Value)
 {
     if (!string.IsNullOrEmpty(TryParse.ToString(Value)))
     {
         KeyValue item = _DataKeyList.Find(q => TryParse.ToString(q.DisplayMember) == TryParse.ToString(Value));
         if (item != null)
         {
             cbDataEditor.SelectedValue = item.ValueMember;
         }
     }
 }
Example #16
0
        public CCardModel GetCard(int id)
        {
            CCardModel model       = null;
            string     commandText =
                @"SELECT cc.ID
       , cc.C_NUMBER
       , cc.VALID_FROM_DATE
       , cc.VALID_TO_DATE
       , cc.IS_BLOCKED
       , c.ID AS CONTRACTOR_ID
       , c.C_NAME AS CONTRACTOR_NAME
       , cc.DISCOUNT_GROUP_ID
       , cc.OWNER_NAME
       , cc.CAR_NUMBER
       , cc.IS_INVOICE
       , cc.IS_MANUAL_INPUT
       , cc.C_COMMENT
       , cc.S_PAYMENT_TYPE_ID
       , cc.C_PASSWORD
 FROM C_CARD cc
 LEFT JOIN CONTRACTOR c ON c.ID = cc.CONTRACTOR_ID
 WHERE cc.ID = " + SQLInt(id);

            using (DataTable dtCCards = FillDataTable(commandText))
            {
                foreach (DataRow drCCard in dtCCards.Rows)
                {
                    model = new CCardModel()
                    {
                        CardId          = TryParse.ToInt32(drCCard["ID"]),
                        CNumber         = TryParse.ToString(drCCard["C_NUMBER"]),
                        ValidFrom       = TryParse.ToDateTime(drCCard["VALID_FROM_DATE"]),
                        ValidTo         = TryParse.ToDateTime(drCCard["VALID_TO_DATE"]),
                        IsBlocked       = (TryParse.ToInt32(drCCard["IS_BLOCKED"]) == 1),
                        ContractorId    = TryParse.ToInt32(drCCard["CONTRACTOR_ID"]),
                        ContractorName  = TryParse.ToString(drCCard["CONTRACTOR_NAME"]),
                        DiscountGroupId = TryParse.ToInt32(drCCard["DISCOUNT_GROUP_ID"], -1),
                        OwnerName       = TryParse.ToString(drCCard["OWNER_NAME"]),
                        CarNumber       = TryParse.ToString(drCCard["CAR_NUMBER"]),
                        IsInvoice       = (TryParse.ToInt32(drCCard["IS_INVOICE"]) == 1),
                        IsManualInput   = (TryParse.ToInt32(drCCard["IS_MANUAL_INPUT"]) == 1),
                        Password        = TryParse.ToString(drCCard["C_PASSWORD"]),
                        Comment         = TryParse.ToString(drCCard["C_COMMENT"]),
                        PaymentTypeId   = TryParse.ToInt32(drCCard["S_PAYMENT_TYPE_ID"])
                    };
                }
            }
            return(model);
        }
Example #17
0
 protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, System.ComponentModel.TypeConverter valueTypeConverter, System.ComponentModel.TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
 {
     if (value != null)
     {
         DataGridViewComboBoxButtonColumn dgcb = this.DataGridView.Columns[this.ColumnIndex] as DataGridViewComboBoxButtonColumn;
         if (dgcb != null)
         {
             KeyValue item = dgcb.DataSource.Find(q => TryParse.ToString(q.ValueMember) == TryParse.ToString(value));
             if (item != null)
             {
                 this.Value = item.ValueMember;
                 return(item.DisplayMember.ToString());
             }
         }
     }
     return(base.GetFormattedValue(value, rowIndex, ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context));
 }
Example #18
0
        private void AdjustConstantUpdate(object value, ref StringBuilder sb)
        {
            if (this.NeedParams)
            {
                ParamInfo p = this.Provider.BuildParamInfo(true, this._ParamList, value, this._CurrentMemberInfo, ref this._paramIndex);

                sb.Append(this.Provider.BuildSpecialName(p.Name));

                _ParamList.Add(p);

                this._paramIndex++;
            }
            else
            {
                string text = TryParse.ToString(value);
                sb.Append(text);
            }
        }
Example #19
0
 protected override void OnCellBeginEdit(DataGridViewCellCancelEventArgs e)
 {
     if (!_EnabledEdit)
     {
         e.Cancel = true;
         return;
     }
     if (e.RowIndex > 0)
     {
         if (ForzenColumn != null)
         {
             if (string.IsNullOrEmpty(TryParse.ToString(this[ForzenColumn.Index, e.RowIndex - 1].Value)))
             {
                 e.Cancel = true;
                 return;
             }
         }
     }
     base.OnCellBeginEdit(e);
 }
Example #20
0
 protected override void OnCellEndEdit(DataGridViewCellEventArgs e)
 {
     base.OnCellEndEdit(e);
     if (ForzenColumn == null)
     {
         return;
     }
     if (this[e.ColumnIndex, e.RowIndex].Value == null)
     {
         return;
     }
     if (string.IsNullOrEmpty(TryParse.ToString(this[e.ColumnIndex, e.RowIndex].Value)))
     {
         return;
     }
     if (string.IsNullOrEmpty(TryParse.ToString(this[ForzenColumn.Index, e.RowIndex].Value)))
     {
         int NextValue = 1;
         if (e.RowIndex > 0)
         {
             NextValue = TryParse.StrToInt(this[ForzenColumn.Index, e.RowIndex - 1].Value) + 1;
         }
         string Value = ("000000000" + NextValue);
         this[ForzenColumn.Index, e.RowIndex].Value = Value.Substring(Value.Length - ForzenColumnLength);
     }
     if (ValidRowIndex.Contains(e.RowIndex))
     {
         ValidRowIndex.Remove(e.RowIndex);
     }
     if (_IsNoNullEmptyColumnIndex != null && _IsNoNullEmptyColumnIndex.Count > 0 && ForzenColumn != null)
     {
         foreach (int columnIndex in _IsNoNullEmptyColumnIndex)
         {
             object value = this[columnIndex, e.RowIndex].Value;
             if (value != null && !ValidRowIndex.Contains(e.RowIndex))
             {
                 ValidRowIndex.Add(e.RowIndex);
             }
         }
     }
 }
Example #21
0
        public List <DiscountKindModel> GetDiscountKinds()
        {
            List <DiscountKindModel> model = new List <DiscountKindModel>();
            string commandText             =
                @"SELECT dk.ID
       , dk.DK_NAME
 FROM DISCOUNT_KIND dk
 ORDER BY dk.DK_NAME ";

            using (DataTable dtDiscounts = FillDataTable(commandText))
            {
                foreach (DataRow drDiscount in dtDiscounts.Rows)
                {
                    model.Add(new DiscountKindModel()
                    {
                        DiscountKindId = TryParse.ToInt32(drDiscount["ID"]),
                        Name           = TryParse.ToString(drDiscount["DK_NAME"])
                    });
                }
            }
            return(model);
        }
Example #22
0
        public List <DiscountGroupModel> GetDiscountGroups()
        {
            List <DiscountGroupModel> model = new List <DiscountGroupModel>();
            string commandText =
                @"SELECT dg.ID AS DISCOUNT_GROUP_ID
       , dg.DG_NAME
 FROM DISCOUNT_GROUP dg
 ORDER BY dg.DG_NAME ";

            using (DataTable dtDiscounts = FillDataTable(commandText))
            {
                foreach (DataRow drDiscount in dtDiscounts.Rows)
                {
                    model.Add(new DiscountGroupModel()
                    {
                        DiscountGroupId = TryParse.ToInt32(drDiscount["DISCOUNT_GROUP_ID"]),
                        Name            = TryParse.ToString(drDiscount["DG_NAME"]),
                    });
                }
            }
            return(model);
        }
Example #23
0
        public AccountModel Login(string userName, string passWord)
        {
            AccountModel model       = null;
            string       commandText =
                @"SELECT a.ID
       , a.A_EMAIL
       , a.FIRST_NAME
       , a.LAST_NAME
       , a.LANGUAGE_CODE
 FROM S_ACCOUNT a
 WHERE a.A_USERNAME = "******"
   AND a.A_PASSWORD = "******"
   AND a.IS_ACTIVE = 1 ";

            using (DataTable dtAccount = FillDataTable(commandText))
            {
                // Има открит логин
                if (dtAccount.Rows.Count == 1)
                {
                    DataRow drAccount = dtAccount.Rows[0];
                    model = new AccountModel()
                    {
                        ActionId     = TryParse.ToInt32(drAccount["ID"]),
                        FirstName    = TryParse.ToString(drAccount["FIRST_NAME"]),
                        LastName     = TryParse.ToString(drAccount["LAST_NAME"]),
                        LanguageCode = TryParse.ToString(drAccount["LANGUAGE_CODE"])
                    };
                    // Отбелязва логването
                    commandText =
                        @"UPDATE S_ACCOUNT
    SET LOGIN_SESSION_ID = " + SQLString(xSession.SessionId) + @"
      , LOGIN_LAST_DATE = GETDATE()
 WHERE ID = " + SQLInt(model.ActionId);

                    ExecuteNonQuery(commandText);
                }
            }
            return(model);
        }
Example #24
0
        protected virtual void ctCopy_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            RightMenu.Hide();
            if (e.ClickedItem.Text == "复制")
            {
                if (this.CurrentCell != null)
                {
                    Clipboard.SetDataObject(TryParse.ToString(this.CurrentCell.Value).Trim());
                }
            }
            else if (e.ClickedItem.Text == "粘贴")
            {
                if (this.CurrentCell != null && !this.CurrentCell.ReadOnly && !this.ReadOnly)
                {
                    IDataObject iData = Clipboard.GetDataObject();

                    if (iData.GetDataPresent(DataFormats.Text))
                    {
                        this.CurrentCell.Value = iData.GetData(DataFormats.Text);
                    }
                }
            }
        }
Example #25
0
 private void ValidRowValue(DataGridViewCellEventArgs e)
 {
     RowMessage = string.Empty;
     if (_IsNoNullEmptyColumnIndex != null && _IsNoNullEmptyColumnIndex.Count > 0 && ForzenColumn != null)
     {
         if (!ValidRowIndex.Contains(e.RowIndex))
         {
             return;
         }
         if (!string.IsNullOrEmpty(TryParse.ToString(this[ForzenColumn.Index, e.RowIndex].Value)) ||
             !string.IsNullOrEmpty(TryParse.ToString(this[e.ColumnIndex, e.RowIndex].EditedFormattedValue)))
         {
             foreach (int item in _IsNoNullEmptyColumnIndex)
             {
                 if (string.IsNullOrEmpty(TryParse.ToString(this[item, e.RowIndex].Value)) &&
                     string.IsNullOrEmpty(TryParse.ToString(this[item, e.RowIndex].EditedFormattedValue)))
                 {
                     RowMessage += "," + this.Columns[item].HeaderText;
                 }
             }
         }
     }
 }
Example #26
0
        /// <summary>
        /// 始终空行显示在最后
        /// </summary>
        /// <param name="e"></param>
        protected override void OnSortCompare(DataGridViewSortCompareEventArgs e)
        {
            if (ForzenColumn == null)
            {
                return;
            }
            //base.OnSortCompare(e);
            if (string.IsNullOrEmpty(TryParse.ToString(this[ForzenColumn.Index, e.RowIndex1].Value)))
            {
                if (e.Column.HeaderCell.SortGlyphDirection == SortOrder.Ascending)
                {
                    e.SortResult = 1;
                }
                else
                {
                    e.SortResult = -1;
                }
            }
            else if (string.IsNullOrEmpty(TryParse.ToString(this[ForzenColumn.Index, e.RowIndex2].Value)))
            {
                if (e.Column.HeaderCell.SortGlyphDirection == SortOrder.Ascending)
                {
                    e.SortResult = -1;
                }
                else
                {
                    e.SortResult = 1;
                }
            }

            else
            {
                e.SortResult = System.String.Compare(TryParse.ToString(e.CellValue1), TryParse.ToString(e.CellValue2));
            }
            e.Handled = true;
        }
Example #27
0
        private void Reload(DataGridView dgvList, DataGridViewRow dgvr, bool NewControl)
        {
            if (dgvList == null || dgvr == null)
            {
                return;
            }
            if (NewControl)
            {
                pnlMain.Controls.Clear();
            }
            int StartY = 5;

            foreach (DataGridViewCell dgvc in dgvr.Cells)
            {
                LableTextBox lblTextBox;
                if (!NewControl)
                {
                    lblTextBox = pnlMain.Controls[dgvList.Columns[dgvc.ColumnIndex].Name] as LableTextBox;
                }
                else
                {
                    lblTextBox                 = new LableTextBox();
                    lblTextBox.Width           = this.Width - 20;
                    lblTextBox.DataControlName = dgvList.Columns[dgvc.ColumnIndex].HeaderText;
                    lblTextBox.Name            = dgvList.Columns[dgvc.ColumnIndex].Name;
                    lblTextBox.Location        = new Point(10, StartY);
                    pnlMain.Controls.Add(lblTextBox);
                    StartY += (lblTextBox.Height + 5);
                }
                lblTextBox.DataViewValue = TryParse.ToString(dgvc.FormattedValue);
            }

            if (btnFirst != null)
            {
                btnFirst.Enabled = true;
            }
            if (btnPrev != null)
            {
                btnPrev.Enabled = true;
            }
            if (btnNext != null)
            {
                btnNext.Enabled = true;
            }
            if (btnLast != null)
            {
                btnLast.Enabled = true;
            }
            if (dgvList.SelectedRows[0].Index == 0)
            {
                if (btnFirst != null)
                {
                    btnFirst.Enabled = false;
                }
                if (btnPrev != null)
                {
                    btnPrev.Enabled = false;
                }
            }
            if (dgvList.SelectedRows[0].Index == dgvList.Rows.Count - 1)
            {
                if (btnNext != null)
                {
                    btnNext.Enabled = false;
                }
                if (btnLast != null)
                {
                    btnLast.Enabled = false;
                }
            }
        }
Example #28
0
        protected override void AdjustConstant(object value, ref StringBuilder sb)
        {
            Type type = value.GetType();

            if (type.IsStringType())
            {
                if (type.IsBooleanType())
                {
                    value = ((bool)value) ? 1 : 0;
                    if ((this.ExcuteType == DMSExcuteType.UPDATE ||
                         this.ExcuteType == DMSExcuteType.UPDATE_WHERE) && this.NeedParams)
                    {
                        AdjustConstantUpdate(value, ref sb);
                        return;
                    }
                    else if ((this.ExcuteType == DMSExcuteType.INSERT ||
                              this.ExcuteType == DMSExcuteType.INSERTIDENTITY ||
                              this.ExcuteType == DMSExcuteType.INSERT_SELECT) && this.NeedParams)
                    {
                        AdjustConstantInsert(value, ref sb);
                        return;
                    }
                    sb.Append(value);
                }
                else
                {
                    if ((this.ExcuteType == DMSExcuteType.UPDATE ||
                         this.ExcuteType == DMSExcuteType.UPDATE_WHERE) && this.NeedParams)
                    {
                        AdjustConstantUpdate(value, ref sb);
                        return;
                    }
                    else if ((this.ExcuteType == DMSExcuteType.INSERT ||
                              this.ExcuteType == DMSExcuteType.INSERTIDENTITY ||
                              this.ExcuteType == DMSExcuteType.INSERT_SELECT) && this.NeedParams)
                    {
                        AdjustConstantInsert(value, ref sb);
                        return;
                    }
                    string text = TryParse.ToString(value);
                    if (text == "*")
                    {
                        sb.Append(text);
                    }
                    else
                    {
                        if (_foundStringToCoumn)
                        {
                            if (this.SplitExpression.TableMapping.TokenFlag == true)
                            {
                                text = this.Provider.BuildColumnName(text);
                            }
                            sb.Append(text);
                        }
                        else
                        {
                            sb.Append("'");
                            sb.Append(text);
                            sb.Append("'");
                        }
                    }
                }
            }
            else
            {
                if ((this.ExcuteType == DMSExcuteType.UPDATE ||
                     this.ExcuteType == DMSExcuteType.UPDATE_WHERE) && this.NeedParams)
                {
                    AdjustConstantUpdate(value, ref sb);
                    return;
                }
                else if ((this.ExcuteType == DMSExcuteType.INSERT ||
                          this.ExcuteType == DMSExcuteType.INSERTIDENTITY ||
                          this.ExcuteType == DMSExcuteType.INSERT_SELECT) && this.NeedParams)
                {
                    AdjustConstantInsert(value, ref sb);
                    return;
                }
                string text = TryParse.ToString(value);
                sb.Append(text);
            }
        }
Example #29
0
        private void ExcuteExport()
        {
            this.ThreadState = EnumGloabParas.EnumThreadState.Run;
            int          totalCount  = this.m_DataTable.Rows.Count;
            int          rowRead     = 0;
            bool         IsCompleted = false;
            string       errMsg      = string.Empty;
            DbConnection conn        = GetConnection(this.ConnectionString);

            if (conn == null)
            {
                this.ThreadState = EnumGloabParas.EnumThreadState.SpiderCompleted;
                errMsg           = "无法获取到数据库连接";
                ExportCompleted(totalCount, errMsg, IsCompleted);
                return;
            }

            if (e_ExportStartingEvent != null)
            {
                e_ExportStartingEvent(this, new cExportStartEventArgs()
                {
                    TotalCount = totalCount,
                });
            }
            try
            {
                conn.Open();
                foreach (DataRow item in this.m_DataTable.Rows)
                {
                    string commandText = this.CommandText;
                    foreach (DataColumn column in m_DataTable.Columns)
                    {
                        string replaceStr = "{" + column.ColumnName + "}";
                        if (commandText.IndexOf(replaceStr) != -1)
                        {
                            string rowValue = TryParse.ToString(item[column.ColumnName]);
                            rowValue    = rowValue.Replace("'", "''");
                            commandText = commandText.Replace(replaceStr, rowValue);
                        }
                    }

                    DbCommand command = conn.CreateCommand();
                    command.CommandText = commandText;
                    int queryCount = command.ExecuteNonQuery();
                    rowRead++;
                    string m       = ((100m * rowRead) / totalCount).ToString();
                    int    percent = TryParse.StrToInt(m);
                    if (e_ExportProgressingEvent != null)
                    {
                        e_ExportProgressingEvent(this, new ExportProgressingArgs()
                        {
                            ExportCount   = rowRead,
                            ExportPercent = percent,
                            TotalCount    = totalCount,
                        });
                    }
                }
                this.ThreadState = EnumGloabParas.EnumThreadState.SpiderCompleted;
                IsCompleted      = true;
            }
            catch (Exception ex)
            {
                this.ThreadState = EnumGloabParas.EnumThreadState.SpiderCompleted;
                IsCompleted      = false;
                errMsg           = ex.Message + ex.Source;
            }
            finally
            {
                if (conn != null && conn.State != ConnectionState.Closed)
                {
                    conn.Close();
                }
                ExportCompleted(totalCount, errMsg, IsCompleted);
            }
        }