Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {

                conn = new Connection();
                string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
                conn.Open(connectionstring);
                Message = Request["Message"];
               UserIPAddress = GetIPAddress();
                //For Demo
                // UserIPAddress = "192.168.1.12";
                Rs1 = new Recordset();
                sql1 = "Select Station From Station Where IPAddress ='" + UserIPAddress + "'";
                Rs1 = conn.Execute(sql1);
                if (!(Rs1.Eof))
                {
                    StationID = Rs1.Fields["Station"].Value;
                    Session["StationID"] = StationID;
                    conn.Close();
                }
                else
                {
                    Alert = "編號未設置, 請提供此電腦的 IP 地址 [ " + UserIPAddress + " ] 給系統管理員";
                }
            }
            catch (Exception ex)
            {

            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        conn = new Connection();

        string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
        conn.Open(connectionstring);
        //For Demo
        UserIPAddress = GetIPAddress();
        //UserIPAddress = Request.ServerVariables["REMOTE_ADDR"];
        Rs1 = new Recordset();
        sql1 = "Select Station From Station Where IPAddress ='" + UserIPAddress + "'";
        Rs1 = conn.Execute(sql1);
        StationID = Rs1.Fields["Station"].Value;
        UserID = Session["UserID"];
        SecLevel = Session["SecLevel"];
        CarPlate = Request["CarPlate"];
        ProductType = Request["ProductType"];
        Message = "";
        if (Convert.ToString(SecLevel) == "")
        {
            Response.Redirect("Default.aspx");
        }
        Session.Add("SecLevel", SecLevel);
        Session.Add("UserID", UserID);
        Session.Add("StationID", StationID);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            conn = new Connection();
           string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
            conn.Open(connectionstring); 
            UserID = (Request["UserID"]).Trim();
            Level = (Request["SecLevel"]).Trim();
            StationID = (Request["StationID"]).Trim();
            UserID = (Request["UserID"]).TrimEnd();
            SDay = Request["SDay"];
            SMonth = Request["SMonth"];
            SYear = Request["SYear"];
            NDay = Request["NDay"];
            NMonth = Request["NMonth"];
            NYear = Request["NYear"];
            // Search_Date = Strings.FormatDateTime(new DateTime(Convert.ToInt32(SYear), Convert.ToInt32(SMonth), Convert.ToInt32(SDay)), (DateFormat)2);
            //Search_NDate = Strings.FormatDateTime(new DateTime(Convert.ToInt32(NYear), Convert.ToInt32(NMonth), Convert.ToInt32(NDay)), (DateFormat)2);

            Search_Date = SDay + "/" + SMonth + "/" + SYear;
            Search_NDate = NDay + "/" + NMonth + "/" + NYear;
            fsql = "select * from MasterCoupon where RequestedID = " + StationID +
                " and  Present_Date >=   Convert(datetime, '" + Search_Date + "', 105) " +
                " and  Present_Date < DATEADD(dd,DATEDIFF(dd,0, Convert(datetime, '" + Search_NDate + "', 105)),0) + 1 " +
                " order by id desc";
            //response.write fsql
            //response.end
            RS1 = conn.Execute(fsql);
           
          
            //Today = Strings.FormatDateTime(DateTime.Now, (DateFormat)2);
            Today = DateTime.Now.ToString("dd-MM-yyyy");
            Response.ContentType = "application/pdf";

            Response.AddHeader("content-disposition", "attachment;filename=§¨é¬ö¿ý(" + Today + ").pdf");       
          //  Write_CSV_From_Recordset(RS1);
            ExportToPDF(RS1, true, StationID);
        }
        catch (Exception ex)
        { 
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        conn = new Connection();
      
        string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
        conn.Open(connectionstring); 
        
        UserIPAddress = GetIPAddress();
        //For Demo            
        //UserIPAddress = "192.168.1.12";
	    //UserIPAddress = Request.ServerVariables["REMOTE_ADDR"];
        Rs1 = new Recordset();
        sql1 = "Select Station , LoginUser  From Station Where IPAddress ='" + UserIPAddress + "'";
        Rs1 = conn.Execute(sql1);
        StationID = Rs1.Fields["Station"].Value;
        UserID = Rs1.Fields["LoginUser"].Value;     
        CarPlate = Request["CarPlate"];
        ProductType = Request["ProductType"];
        Message = "";     
        
    }
Example #5
0
 public void EnableActive(int supplierId)
 {
     Connection.Execute("update Supplier set isActive ='1'  where   SupplierId =@Id ", param: new { Id = supplierId }, transaction: Transaction);
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="instance"></param>
        /// <returns></returns>
        public virtual bool Update(TEntity instance)
        {
            var sql = SqlGenerator.GetUpdate();

            return(Connection.Execute(sql, instance) > 0);
        }
Example #7
0
        /**
         * Items that are in NEW table
         * but not in OLD table are
         * marked as CREATED
         */
        protected virtual void CheckNewItems(IndexColumnMapping idColumn,
                                             IEnumerable <IndexColumnMapping> primaryColumns,
                                             IEnumerable <IndexColumnMapping> valueColumns,
                                             IEnumerable <IndexColumnMapping> columnsNotId,
                                             string tmpTable)
        {
            var indexer           = GetIndexModel();
            var comparePrimarySQL = $@"o.[Id] = n.[{idColumn.SourceName}]";

            if (primaryColumns?.Count() > 0)
            {
                comparePrimarySQL = string.Join(" AND ", primaryColumns
                                                .Select(c => $@"o.[{c.MappingName}] = n.[{c.SourceName}]")
                                                .Union(new List <string> {
                    $"o.[Id] = n.[{idColumn.SourceName}]"
                }));
            }

            var mergeCondition = $@"s.[Id] = t.[SourceId]"; // column Id in NewTable is [SourceId] in ValueTable

            if (primaryColumns?.Count() > 0)                // Both tables have same Primary Columns and Value Columns
            {
                mergeCondition = string.Join(" AND ", primaryColumns
                                             .Select(c => $@"s.[{c.MappingName}] = t.[{c.MappingName}]")
                                             .Union(new List <string> {
                    $"s.[Id] = t.[SourceId]"
                }));
            }
            var mappingColumns = columnsNotId.Union(new List <IndexColumnMapping> {
                idColumn
            });
            var sourceColumns = mappingColumns.Select(c => $"n.[{c.SourceName}] AS [{c.MappingName}]");
            var mergeSQL      = $@"
MERGE INTO [{indexer.ValueTableName}] as t
USING (
    SELECT {string.Join(", ", sourceColumns)}
    FROM {tmpTable} n
    LEFT JOIN [{indexer.OldValueTableName}] AS o ON {comparePrimarySQL}
    WHERE o.[Id] IS NULL
)
AS s
ON {mergeCondition}
WHEN NOT MATCHED THEN
	INSERT (
        [SourceId],
        [DestinationId],
        [State],
        [LastUpdated],
        {string.Join(",\n", columnsNotId.Select(c => $"[{c.MappingName}]"))}
    )
    VALUES(
        s.[Id],
        NULL,
        @State,
        @LastUpdated,
        {string.Join(",\n", columnsNotId.Select(c => $"s.[{c.MappingName}]"))}
    )
WHEN MATCHED AND ([State] & {(int)ItemState.Removed}) > 0 THEN
    UPDATE SET 
        [State] = @State,
        [LastUpdated] = @LastUpdated,
        {string.Join(",\n", columnsNotId.Select(c => $"[{c.MappingName}] = s.[{c.MappingName}]"))};
";
            var affectedRows  = Connection.Execute(mergeSQL, param: new {
                State       = ItemState.Changed,
                LastUpdated = DateTime.Now.ToUnixTimestamp()
            }, transaction: Transaction);

            Report($@"Found {affectedRows} new item(s)");
        }
Example #8
0
 public void PersistDeletedItem(SaveInfo item)
 {
     Connection.Execute(IoC.Resolve <IMapper>().GetRemoveCommand(item.Info.GetType()), item.Info, Transaction);
 }
Example #9
0
 public virtual int Execute(string sql, object param = null, CommandType?commandType = null, int?commandTimeout = null)
 => Execute(() => Connection.Execute(sql, param, _currentTransaction, commandTimeout, commandType), SqlType.DML);
        public DataTypesFixture()
        {
            Connection.Open();
            Connection.Execute(@"
drop table if exists datatypes_bools;
create table datatypes_bools(
  rowid integer not null primary key auto_increment,
  Boolean bool null,
  TinyInt1 tinyint(1) null
);

insert into datatypes_bools(Boolean, TinyInt1)
values
  (null, null),
  (0, 0),
  (1, 1),
  (false, false),
  (true, true),
  (-1, -1),
  (123, 123);

drop table if exists datatypes_bits;
create table datatypes_bits(
  rowid integer not null primary key auto_increment,
  Bit1 bit(1) null,
  Bit32 bit(32) null,
  Bit64 bit(64) null
);

insert into datatypes_bits(Bit1, Bit32, Bit64)
values
  (null, null, null),
  (0, 0, 0),
  (1, 1, 1),
  (1, X'FFFFFFFF', X'FFFFFFFFFFFFFFFF');

drop table if exists datatypes_enums;
create table datatypes_enums(
	rowid integer not null primary key auto_increment,
	size enum('x-small', 'small', 'medium', 'large', 'x-large'),
	color enum('red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet') not null
);

insert into datatypes_enums(size, color)
values
	(null, 'red'),
	('small', 'orange'),
	('medium', 'green');

drop table if exists datatypes_integers;
create table datatypes_integers (
  rowid integer not null primary key auto_increment,
  SByte tinyint null,
  Byte tinyint unsigned null,
  Int16 smallint null,
  UInt16 smallint unsigned null,
  Int24 mediumint null,
  UInt24 mediumint unsigned null,
  Int32 int null,
  UInt32 int unsigned null,
  Int64 bigint null,
  UInt64 bigint unsigned null
);

insert into datatypes_integers(SByte, Byte, Int16, UInt16, Int24, UInt24, Int32, UInt32, Int64, UInt64)
values
  (null, null, null, null, null, null, null, null, null, null), # null
  (0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # zero
  (-128, 0, -32768, 0, -8388608, 0, -2147483648, 0, -9223372036854775808, 0), # minimum
  (127, 255, 32767, 65535, 8388607, 16777215, 2147483647, 4294967295, 9223372036854775807, 18446744073709551615), # maximum
  (123, 123, 12345, 12345, 1234567, 1234567, 123456789, 123456789, 1234567890123456789, 1234567890123456789);

drop table if exists datatypes_reals;
create table datatypes_reals(
  rowid integer not null primary key auto_increment,
  Single float null,
  `Double` double null,
  SmallDecimal decimal(5, 2) null,
  MediumDecimal decimal(28, 8) null,
  BigDecimal decimal(50, 30) null
);

insert into datatypes_reals(Single, `Double`, SmallDecimal, MediumDecimal, BigDecimal)
values
  (null, null, null, null, null),
  (0, 0, 0, 0, 0),
  (-3.402823466e38, -1.7976931348623157e308, -999.99, -999999999999.99999999, -99999999999999999999.999999999999999999999999999999),
  (-1.401298E-45, -4.94065645841247e-324, -0.01, -0.00000001, -0.000000000000000000000000000001),
  (3.402823466e38, 1.7976931348623157e308, 999.99, 999999999999.99999999, 99999999999999999999.999999999999999999999999999999),
  (1.401298E-45, 4.94065645841247e-324, 0.01, 0.00000001, 0.000000000000000000000000000001);

drop table if exists datatypes_set;
create table datatypes_set(
	rowid integer not null primary key auto_increment,
	value set('one', 'two', 'four') null
);

insert into datatypes_set(value)
values
	(null),
	(''),
	('one'),
	('two'),
	('one,two'),
	('four'),
	('one,four'),
	('two,four'),
	('one,two,four');

drop table if exists datatypes_strings;
create table datatypes_strings (
  rowid integer not null primary key auto_increment,
  utf8 varchar(300) character set 'utf8mb4' null,
  utf8bin varchar(300) character set utf8mb4 collate utf8mb4_bin null,
  latin1 varchar(300) character set 'latin1' null,
  latin1bin varchar(300) character set latin1 collate latin1_bin null,
  cp1251 varchar(300) character set 'cp1251' null,
  guid char(36) null,
  guidbin char(36) binary null
);

insert into datatypes_strings(utf8, utf8bin, latin1, latin1bin, cp1251, guid, guidbin)
values
  (null, null, null, null, null, null, null),
  ('', '', '', '', '', '00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000'),
  ('ASCII', 'ASCII', 'ASCII', 'ASCII', 'ASCII', '00000000-0000-0000-c000-000000000046', '00000000-0000-0000-c000-000000000046'),
  ('Ũńıċōđĕ', 'Ũńıċōđĕ', 'Lãtïñ', 'Lãtïñ', 'АБВГабвг', 'fd24a0e8-c3f2-4821-a456-35da2dc4bb8f', 'fd24a0e8-c3f2-4821-a456-35da2dc4bb8f'),
  ('This string has exactly 251 characters in it. The encoded length is stored as 0xFC 0xFB 0x00. 0xFB (i.e., 251) is the sentinel byte indicating ""this field is null"". Incorrectly interpreting the (decoded) length as the sentinel byte would corrupt data.',
   'This string has exactly 251 characters in it. The encoded length is stored as 0xFC 0xFB 0x00. 0xFB (i.e., 251) is the sentinel byte indicating ""this field is null"". Incorrectly interpreting the (decoded) length as the sentinel byte would corrupt data.',
   'This string has exactly 251 characters in it. The encoded length is stored as 0xFC 0xFB 0x00. 0xFB (i.e., 251) is the sentinel byte indicating ""this field is null"". Incorrectly interpreting the (decoded) length as the sentinel byte would corrupt data.',
   'This string has exactly 251 characters in it. The encoded length is stored as 0xFC 0xFB 0x00. 0xFB (i.e., 251) is the sentinel byte indicating ""this field is null"". Incorrectly interpreting the (decoded) length as the sentinel byte would corrupt data.',
   'This string has exactly 251 characters in it. The encoded length is stored as 0xFC 0xFB 0x00. 0xFB (i.e., 251) is the sentinel byte indicating ""this field is null"". Incorrectly interpreting the (decoded) length as the sentinel byte would corrupt data.',
   '6a0e0a40-6228-11d3-a996-0050041896c8', '6a0e0a40-6228-11d3-a996-0050041896c8');

drop table if exists datatypes_blobs;
create table datatypes_blobs(
  rowid integer not null primary key auto_increment,
  `Binary` binary(100) null,
  `VarBinary` varbinary(100) null,
  `TinyBlob` tinyblob null,
  `Blob` blob null,
  `MediumBlob` mediumblob null,
  `LongBlob` longblob null,
  guidbin binary(16) null
);

insert into datatypes_blobs(`Binary`, `VarBinary`, `TinyBlob`, `Blob`, `MediumBlob`, `LongBlob`, guidbin)
values
  (null, null, null, null, null, null, null),
  (X'00112233445566778899AABBCCDDEEFF',
    X'00112233445566778899AABBCCDDEEFF',
    X'00112233445566778899AABBCCDDEEFF',
    X'00112233445566778899AABBCCDDEEFF',
    X'00112233445566778899AABBCCDDEEFF',
    X'00112233445566778899AABBCCDDEEFF',
    X'00112233445566778899AABBCCDDEEFF');

drop table if exists datatypes_times;
create table datatypes_times(
  rowid integer not null primary key auto_increment,
  `Date` date null,
  `DateTime` datetime(6) null,
  `Timestamp` timestamp(6) null,
  `Time` time(6) null,
  `Year` year null);

insert into datatypes_times(`Date`, `DateTime`, `Timestamp`, `Time`, `Year`)
values
  (null, null, null, null, null),
  (date '1000-01-01', timestamp '1000-01-01 00:00:00', timestamp '1970-01-01 00:00:01', time '-838:59:59' , 1901),
  (date '9999-12-31', timestamp '9999-12-31 23:59:59.999999', '2038-01-18 03:14:07.999999', time '838:59:59.000', 2155), -- not actually maximum Timestamp value, due to TZ conversion
  (null, null, null, time '00:00:00', 0),
  (date '2016-04-05', timestamp '2016-04-05 14:03:04.56789', timestamp '2016-04-05 14:03:04.56789', time '14:03:04.56789', 2016);

drop table if exists datatypes_guids;
create table datatypes_guids (
  rowid integer not null primary key auto_increment,
  char38 char(38) null,
  char38bin char(38) binary null,
  `text` text null,
  `blob` blob null
);

insert into datatypes_guids (char38, char38bin, `text`, `blob`)
values
  (null, null, null, null),
  ('0', '0', '0', X'00'),
  ('33221100-5544-7766-8899-aabbccddeeff', '33221100-5544-7766-8899-aabbccddeeff',
    '33221100-5544-7766-8899-aabbccddeeff', X'00112233445566778899AABBCCDDEEFF'),
  ('{33221100-5544-7766-8899-aabbccddeeff}', '{33221100-5544-7766-8899-aabbccddeeff}',
    '{33221100-5544-7766-8899-aabbccddeeff}', X'00112233445566778899AABBCCDDEEFF');
");

            if (AppConfig.SupportsJson)
            {
                Connection.Execute(@"
drop table if exists datatypes_json_core;
create table datatypes_json_core (
  rowid integer not null primary key auto_increment,
  value json null
);

insert into datatypes_json_core (value)
values
  (null),
  ('null'),
  ('true'),
  ('[]'),
  ('[0]'),
  ('[1]'),
  ('0'),
  ('1'),
  ('{}'),
  ('{""a"": ""b""}');
");
            }
        }
Example #11
0
 public virtual bool Restore(int id) => Connection.Execute($"update {TableName} set IsDeleted = 0, DateModified = getdate() where Id = {id}") > 0;
Example #12
0
 /// <summary>
 /// 执行SQL语句并返会影响行数
 /// </summary>
 /// <param name="sql"></param>
 /// <param name="param"></param>
 /// <param name="text"></param>
 /// <returns></returns>
 public int Execute(string sql, object param = null, CommandType text = CommandType.Text)
 {
     return(Connection.Execute(sql, param, Transaction, Timeout, text));
 }
Example #13
0
 public override int Execute(string sql, object parameter = null, int?commandTimeout = null, CommandType?commandType = null)
 {
     return(Connection.Execute(sql, parameter, Transaction, commandTimeout, commandType));
 }
Example #14
0
 public void Remove(int id)
 {
     Connection.Execute("delete from DebtDetail where DebtDetailId = @Id", param: new { Id = id }, transaction: Transaction);
 }
 public void Remove(SkillGroup skillGroup)
 {
     Connection.Execute("DELETE FROM [SkillGroup] WHERE [SkillGroupId]=@SkillGroupId", skillGroup);
 }
Example #16
0
 public void DeleteGroupSupplier(int GroupID)
 {
     Connection.Execute("delete  from GroupSupplier where GroupID =  @GroupID ", param: new { GroupID = GroupID }, transaction: Transaction);
 }
Example #17
0
 public void Updategroupsupplier(GroupSupplier groupsupplier)
 {
     Connection.Execute("update GroupSupplier set GroupName  =@GroupName, ApproveStatusId =@ApproveStatusId where GroupID =   @GroupID ", param: new { GroupID = groupsupplier.GroupId, GroupName = groupsupplier.GroupName, ApproveStatusId = groupsupplier.ApproveStatusId }, transaction: Transaction);
 }
Example #18
0
        public override Lfx.Types.OperationResult Ok()
        {
            int PV       = EntradaPV.ValueInt;
            int Desde    = EntradaDesde.ValueInt;
            int Hasta    = EntradaHasta.ValueInt;
            int Cantidad = Hasta - Desde + 1;

            Lui.Forms.YesNoDialog Pregunta = new Lui.Forms.YesNoDialog("Una vez anulados, los comprobantes deberán ser archivados en todas sus copias y no podrán ser rehabilitados ni reutilizados.", "¿Está seguro de que desea anular " + Cantidad.ToString() + " comprobantes?");
            Pregunta.DialogButtons = Lui.Forms.DialogButtons.YesNo;

            if (Pregunta.ShowDialog() == DialogResult.OK)
            {
                bool AnularPagos = EntradaAnularPagos.ValueInt != 0;

                int    m_Id         = 0;
                string IncluyeTipos = "";

                switch (EntradaTipo.TextKey)
                {
                case "A":
                    IncluyeTipos = "'FA', 'NCA', 'NDA'";
                    break;

                case "B":
                    IncluyeTipos = "'FB', 'NCB', 'NDB'";
                    break;

                case "C":
                    IncluyeTipos = "'FC', 'NCC', 'NDC'";
                    break;

                case "E":
                    IncluyeTipos = "'FE', 'NCE', 'NDE'";
                    break;

                case "M":
                    IncluyeTipos = "'FM', 'NCM', 'NDM'";
                    break;

                case "T":
                    IncluyeTipos = "'T'";
                    break;

                default:
                    IncluyeTipos = "'" + EntradaTipo.TextKey + "'";
                    break;
                }

                Lfx.Types.OperationProgress Progreso = new Lfx.Types.OperationProgress("Anulando comprobantes", "Se están anulando los comprobantes seleccionados.");
                Progreso.Cancelable = true;
                Progreso.Max        = Cantidad;
                Progreso.Begin();

                IDbTransaction Trans = this.Connection.BeginTransaction(IsolationLevel.Serializable);
                for (int Numero = Desde; Numero <= Hasta; Numero++)
                {
                    int IdFactura = Connection.FieldInt("SELECT id_comprob FROM comprob WHERE impresa=1 AND tipo_fac IN (" + IncluyeTipos + ") AND pv=" + PV.ToString() + " AND numero=" + Numero.ToString());

                    if (IdFactura == 0)
                    {
                        // Es una factura que todava no existe
                        // Tengo que crear la factura y anularla
                        qGen.Insert InsertarComprob = new qGen.Insert("comprob");
                        InsertarComprob.Fields.AddWithValue("tipo_fac", "F" + EntradaTipo.TextKey);
                        InsertarComprob.Fields.AddWithValue("id_formapago", 3);
                        InsertarComprob.Fields.AddWithValue("id_sucursal", Lfx.Workspace.Master.CurrentConfig.Empresa.SucursalActual);
                        InsertarComprob.Fields.AddWithValue("pv", Lfx.Types.Parsing.ParseInt(EntradaPV.Text));
                        InsertarComprob.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
                        InsertarComprob.Fields.AddWithValue("id_vendedor", Lbl.Sys.Config.Actual.UsuarioConectado.Id);
                        InsertarComprob.Fields.AddWithValue("id_cliente", Lbl.Sys.Config.Actual.UsuarioConectado.Id);
                        InsertarComprob.Fields.AddWithValue("obs", "Comprobante anulado antes de ser impreso.");
                        InsertarComprob.Fields.AddWithValue("impresa", 1);
                        InsertarComprob.Fields.AddWithValue("anulada", 1);
                        Connection.Execute(InsertarComprob);
                        m_Id = Connection.FieldInt("SELECT LAST_INSERT_ID()");
                        Lbl.Comprobantes.ComprobanteConArticulos NuevoComprob = new Lbl.Comprobantes.ComprobanteConArticulos(this.Connection, m_Id);
                        NuevoComprob.Numerar(true);
                    }
                    else
                    {
                        Lbl.Comprobantes.ComprobanteConArticulos Fac = new Lbl.Comprobantes.ComprobanteConArticulos(Connection, IdFactura);
                        if (Fac.Anulado == false)
                        {
                            Fac.Anular(AnularPagos);
                        }
                    }

                    Progreso.Advance(1);
                    if (Progreso.Cancelar)
                    {
                        break;
                    }
                }

                Progreso.End();

                if (Progreso.Cancelar)
                {
                    Trans.Rollback();
                    Lfx.Workspace.Master.RunTime.Toast("La operación fue cancelada.", "Aviso");
                }
                else
                {
                    Trans.Commit();
                    ProximosNumeros.Clear();
                    Lui.Forms.MessageBox.Show("Se anularon los comprobantes seleccionados. Recuerde archivar ambas copias.", "Aviso");
                }

                EntradaDesde.ValueInt = 0;
                EntradaHasta.ValueInt = 0;
                EntradaDesde.Focus();

                return(base.Ok());
            }
            else
            {
                return(new Lfx.Types.FailureOperationResult("La operación fue cancelada."));
            }
        }
 public void Remove(long id)
 {
     Connection.Execute(SqlCommand.Remove,
                        param: new { Id = id },
                        transaction: Transaction);
 }
Example #20
0
        public override void Add(ProcedureMedicine item)
        {
            var query = "insert into ProcedureMedicine (MedicineId, ProcedureId, Count) values (@MedicineId, @ProcedureId, @Count)";

            Connection.Execute(query, item);
        }
Example #21
0
        public void Delete(int carritoItemId)
        {
            var query = "DELETE FROM CarritoItem WHERE  CarritoItemId=@CarritoItemId";

            Connection.Execute(query, new { carritoItemId }, transaction: Transaction);
        }
Example #22
0
 public void ExecuteComposition(string script)
 {
     Connection.Execute(script, null);
 }
Example #23
0
 protected void btNewSave_Click(object sender, EventArgs e)
 {
     Conn.Execute("GenNewDataStandard59", "StudyYear", Convert.ToInt32(txtNextYear.Text));
     DataBind();
 }
Example #24
0
 public void Remove(int id)
 {
     Connection.Execute("delete from RequestSent where RequestSentId = @RequestSentId", param: new { Id = id }, transaction: Transaction);
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public virtual bool Delete(object key)
        {
            var sql = SqlGenerator.GetDelete();

            return(Connection.Execute(sql, key) > 0);
        }
Example #26
0
    protected void btSave_Click(object sender, EventArgs e)
    {
        StringBuilder strbSql = new StringBuilder();
        int           x       = 0;

        if (CkDuplicate(txtNextYear.Text))
        {
            Response.Redirect("CopySuffice.aspx?ckmode=7&Cr=0");
        }
        string   strSql        = @" Select SufficeSideID, SufficeSideName, Detail, Sort 
                From SufficeSide Where DelFlag = 0 And StudyYear = '{0}' Order By Sort ";
        DataView dvSufficeSide = Conn.Select(string.Format(strSql, ddlYearB.SelectedValue));

        strSql = @" Select b.SufficeStandardID, b.SufficeStandardName, b.SufficeSideID, b.Detail, b.Sort 
                From SufficeSide a, SufficeStandard b 
                Where b.DelFlag = 0 And a.StudyYear = '{0}' And a.SufficeSideID = b.SufficeSideID Order By b.Sort ";
        DataView dvSufficeStandard = Conn.Select(string.Format(strSql, ddlYearB.SelectedValue));

        strSql = @" Select c.SufficeIndicatorID, c.SufficeIndicatorName, c.SufficeStandardID, c.Detail, c.Sort 
                From SufficeSide a, SufficeStandard b, SufficeIndicator c 
                Where c.DelFlag = 0 And a.StudyYear = '{0}' And a.SufficeSideID = b.SufficeSideID And b.SufficeStandardID = c.SufficeStandardID Order By c.Sort ";
        DataView dvSufficeIndicator = Conn.Select(string.Format(strSql, ddlYearB.SelectedValue));

        if (dvSufficeSide.Count != 0)
        {
            for (int i = 0; i < dvSufficeSide.Count; i++)
            {
                string NewSufficeSideID = Guid.NewGuid().ToString();
                strbSql.AppendFormat("INSERT INTO SufficeSide (SufficeSideID, StudyYear, SufficeSideName, Detail, Sort, DelFlag, CreateDate, CreateUser, UpdateDate, UpdateUser)VALUES('{0}',{1},N'{2}',N'{3}',{4},{5},'{6}','{7}','{8}','{9}');",
                                     NewSufficeSideID, txtNextYear.Text, dvSufficeSide[i]["SufficeSideName"].ToString(), dvSufficeSide[i]["Detail"].ToString(), Convert.ToInt32(dvSufficeSide[i]["Sort"]), 0, DateTime.Now, CurrentUser.ID, DateTime.Now, CurrentUser.ID);

                dvSufficeStandard.RowFilter = " SufficeSideID = '" + dvSufficeSide[i]["SufficeSideID"].ToString() + "' ";

                if (dvSufficeStandard.Count != 0)
                {
                    for (int j = 0; j < dvSufficeStandard.Count; j++)
                    {
                        string NewSufficeStandard = Guid.NewGuid().ToString();
                        strbSql.AppendFormat("INSERT INTO SufficeStandard (SufficeStandardID, SufficeSideID, SufficeStandardName, Detail, Sort, DelFlag, CreateDate, CreateUser, UpdateDate, UpdateUser)VALUES('{0}','{1}',N'{2}',N'{3}',{4},{5},'{6}','{7}','{8}','{9}');",
                                             NewSufficeStandard, NewSufficeSideID, dvSufficeStandard[j]["SufficeStandardName"].ToString(), dvSufficeStandard[j]["Detail"].ToString(), Convert.ToInt32(dvSufficeStandard[j]["Sort"]), 0, DateTime.Now, CurrentUser.ID, DateTime.Now, CurrentUser.ID);

                        dvSufficeIndicator.RowFilter = " SufficeStandardID = '" + dvSufficeStandard[j]["SufficeStandardID"].ToString() + "' ";

                        if (dvSufficeIndicator.Count != 0)
                        {
                            for (int k = 0; k < dvSufficeIndicator.Count; k++)
                            {
                                string NewSufficeIndicator = Guid.NewGuid().ToString();
                                strbSql.AppendFormat("INSERT INTO SufficeIndicator (SufficeIndicatorID, SufficeStandardID, SufficeIndicatorName, Detail, Sort, DelFlag, CreateDate, CreateUser, UpdateDate, UpdateUser)VALUES('{0}','{1}',N'{2}',N'{3}',{4},{5},'{6}','{7}','{8}','{9}');",
                                                     NewSufficeIndicator, NewSufficeStandard, dvSufficeIndicator[k]["SufficeIndicatorName"].ToString(), dvSufficeIndicator[k]["Detail"].ToString(), Convert.ToInt32(dvSufficeIndicator[k]["Sort"]), 0, DateTime.Now, CurrentUser.ID, DateTime.Now, CurrentUser.ID);
                            }
                        }
                    }
                }
            }
            x = Conn.Execute(strbSql.ToString());
            Response.Redirect("CopySuffice.aspx?ckmode=1&Cr=" + x);
        }
        else
        {
            Response.Redirect("CopySuffice.aspx?ckmode=6&Cr=0");
        }
    }
Example #27
0
 /// <inheritdoc/>
 public void Delete(Image entity)
 {
     Connection.Execute("DELETE FROM public.images WHERE id = @id", new { id = entity.Id }, Transaction);
 }
Example #28
0
        public void deletegroup(GroupSupplier m_groupsupplier)
        {
            string delete = ("delete from GroupSupplier  where GroupID = " + m_groupsupplier.GroupId);

            Connection.Execute("delete from GroupSupplier  where GroupID  =@GroupID", param: new { GroupID = m_groupsupplier.GroupId }, transaction: Transaction);
        }
Example #29
0
        /**
         * Items that are both in NEW & OLD tables
         * but with different lookup values (not primary keys)
         * are marked as UPDATED
         */
        protected virtual void CheckChangedItems(IndexColumnMapping idColumn,
                                                 IEnumerable <IndexColumnMapping> primaryColumns,
                                                 IEnumerable <IndexColumnMapping> valueColumns,
                                                 IEnumerable <IndexColumnMapping> columnsNotId,
                                                 string tmpTable)
        {
            if (valueColumns == null || valueColumns.Count() <= 0)
            {
                // No value columns means no different check
                return;
            }

            var    indexer           = GetIndexModel();
            string comparePrimarySQL = $@"o.[Id] = n.[{idColumn.SourceName}]";

            if (primaryColumns?.Count() > 0)
            {
                comparePrimarySQL = string.Join(" AND ", primaryColumns
                                                .Select(c => $@"o.[{c.MappingName}] = n.[{c.SourceName}]")
                                                .Union(new List <string> {
                    $"o.[Id] = n.[{idColumn.SourceName}]"
                }));
            }
            var compareValueSQL = string.Join(" OR ", valueColumns.Select(c => $@"o.[{c.MappingName}] <> n.[{c.SourceName}]"));
            var mergeCondition  = $@"s.[Id] = t.[SourceId]";

            if (primaryColumns?.Count() > 0)
            {
                mergeCondition = string.Join(" AND ", primaryColumns.Select(c => $@"s.[{c}] = t.[{c.MappingName}]").Union(new List <string> {
                    $"s.[Id] = t.[SourceId]"
                }));
            }
            var mappingColumns = columnsNotId.Union(new List <IndexColumnMapping> {
                idColumn
            });
            var sourceColumns = mappingColumns.Select(c => $"n.[{c.SourceName}] AS [{c.MappingName}]");
            var mergeSQL      = $@"
MERGE INTO [{indexer.ValueTableName}] as t
USING (
    SELECT {string.Join(", ", sourceColumns)}
    FROM {tmpTable} n
    LEFT JOIN [{indexer.OldValueTableName}] AS o ON {comparePrimarySQL}
    LEFT JOIN [{indexer.ValueTableName}] AS v ON v.SourceId = o.Id
    WHERE o.[Id] IS NOT NULL AND (
        ({compareValueSQL}) -- Some values is not matched
        OR (v.[State] IS NOT NULL AND (v.[State] & {(int)ItemState.Removed}) > 0) -- Item was marked as 'Removed' but now it is back again
    )
)
AS s
ON {mergeCondition}
WHEN MATCHED THEN
    UPDATE SET 
        [State] = CASE  
                WHEN [State] = 0 THEN @State
                WHEN [State] IS NULL THEN @State 
                ELSE ([State] | @State | @StatesToExclude) ^ @StatesToExclude
            END,
        [LastUpdated] = @LastUpdated,
        {string.Join(",\n", valueColumns.Select(c => $"[{c.MappingName}] = s.[{c.MappingName}]"))};
";

            var affectedRows = Connection.Execute(mergeSQL, param: new
            {
                State           = ItemState.Changed,
                StatesToExclude = ItemState.Removed,
                LastUpdated     = DateTime.Now.ToUnixTimestamp()
            }, transaction: Transaction);

            Report($@"Found {affectedRows} updated item(s)");
        }
Example #30
0
    protected void Page_Load(object sender, EventArgs e)
    {
         conn = new Connection();
         string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
         conn.Open(connectionstring); 
      
        UserIPAddress = GetIPAddress();
        //For Demo            
        //UserIPAddress = "192.168.1.12";
        //UserIPAddress = Request.ServerVariables["REMOTE_ADDR"];
        Rs1 = new Recordset();
       sql1 = "Select * From Station s Left Join CVSUser u on ";

       sql1 = sql1 +  " s.LoginUser = u.UserName Where IPAddress ='" + UserIPAddress + "'";
        Rs1 = conn.Execute(sql1);
        StationID = (Rs1.Fields["Station"].Value).ToString().Trim();
        UserID = (Rs1.Fields["LoginUser"].Value).ToString().Trim();
        SecLevel = (Rs1.Fields["SecLevel"].Value).ToString().Trim();

        if (UserID == "")
        {
            Response.Redirect("Default.aspx");
        }
        Message = Request["Message"];
        Coupon_Number = Request["Coupon_Number"];
        Car_No = Request["Car_No"];
        Face_Value = Request["Face_Value"];
        Period = Request["Period"];
        //search by date
        if (Request["SDay"] != null)
        {
            SDay = Request["SDay"];
            SMonth = Request["SMonth"];
            SYear = Request["SYear"];
        }
        else
        {
            SDay = Convert.ToString(DateTime.Now.Day);
            SMonth = Convert.ToString(DateTime.Now.Month);
            SYear = Convert.ToString(DateTime.Now.Year);
        }
        if (Request["NDay"] != null)
        {
            NDay = Request["NDay"];
            NMonth = Request["NMonth"];
            NYear = Request["NYear"];
        }
        else
        {
            NDay = Convert.ToString(DateTime.Now.Day);
            NMonth = Convert.ToString(DateTime.Now.Month);
            NYear = Convert.ToString(DateTime.Now.Year);
        }
        //Search_Date = Formatdatetime(DateSerial(SYear, SMonth, SDay),2)
        //Search_NDate = Formatdatetime(DateSerial(NYear, NMonth, NDay),2)
        Search_Date = SDay + "/" + SMonth + "/" + SYear;
        Search_NDate = NDay + "/" + NMonth + "/" + NYear;
        //Response.write search_date
        //response.write SecLevel & "<br>"
        //response.write UserID

        if (Request.Form["pageid"] != null)
            pageid = (Request.Form["pageid"]).Trim();
        if (pageid == "")
        {
            pageid = "1";
        }
        if (Request.Form["Barcode"] != null)
        {
            Barcode = (Request.Form["Barcode"]).Trim().Replace("%", "%");
            Barcode = Barcode.Replace("'", "''");
            if (Barcode.Length == 15)
            {
                Face_Value = Barcode.Substring(0, 3);
                Coupon_Type = Barcode.Substring(5 - 1, 2);
                Coupon_batch = Barcode.Substring(7 - 1, 3);
                Coupon_Number = Barcode.Substring(10 - 1, 6);
            }
        }
        fsql = "select * from MasterCoupon where RequestedID = " + Convert.ToString(StationID);
        //Search Coupon Number
        //********************
        if (Barcode != "")
        {
            if (Barcode.Length == 15)
            {
                fsql = fsql + " and Coupon_Number = '" + Coupon_Number + "'";
                fsql = fsql + " and Face_Value = '" + Face_Value + "'";
                fsql = fsql + " and Coupon_Type = '" + Coupon_Type + "'";
                fsql = fsql + " and Coupon_Batch = '" + Coupon_batch + "'";
            }
            else
            {
                fsql = fsql + " and Coupon_Number LIKE '%" + Barcode + "%' ";
            }
        }
        fsql = fsql + " and  Present_Date >=   Convert(datetime, '" + Convert.ToString(Search_Date) + "', 105) ";
        fsql = fsql + " and  Present_Date < DATEADD(dd,DATEDIFF(dd,0, Convert(datetime, '" + Convert.ToString(Search_NDate) + "', 105)),0) + 1 ";
        //By UserID
        if (Convert.ToString(SecLevel).Trim() == "1")
        {
            fsql = fsql + " and Period = '" + Convert.ToString(UserID) + "' ";
        }
        fsql = fsql + " order by id desc";
        frs = new Recordset();
        frs.CursorType = (nce.adodb.CursorType)1;
        frs.LockType = (nce.adodb.LockType)1;
        Rs1.Close();
        frs.Open(fsql, conn);       
    }
Example #31
0
 public void Excluir(Medico medico)
 {
     Connection.Execute("delete from medico where id = @id", medico);
 }
Example #32
0
 public void Remove(int supplierId)
 {
     Connection.Execute("delete from Supplier where SupplierId = @SupplierId ", param: new { SupplierId = supplierId }, transaction: Transaction);
 }
Example #33
0
        internal void Execute (HyenaSqliteConnection hconnection, Connection connection)
        {
            if (finished) {
                throw new Exception ("Command is already set to finished; result needs to be claimed before command can be rerun");
            }

            execution_exception = null;
            result = null;
            int execution_ms = 0;

            string command_text = null;
            try {
                command_text = CurrentSqlText;
                ticks = System.Environment.TickCount;

                switch (CommandType) {
                    case HyenaCommandType.Reader:
                        using (var reader = connection.Query (command_text)) {
                            result = new ArrayDataReader (reader, command_text);
                        }
                        break;

                    case HyenaCommandType.Scalar:
                        result = connection.Query<object> (command_text);
                        break;

                    case HyenaCommandType.Execute:
                    default:
                        connection.Execute (command_text);
                        result = connection.LastInsertRowId;
                        break;
                }

                execution_ms = System.Environment.TickCount - ticks;
                if (log_all) {
                    Log.DebugFormat ("Executed in {0}ms {1}", execution_ms, command_text);
                } else if (Log.Debugging && execution_ms > 500) {
                    Log.WarningFormat ("Executed in {0}ms {1}", execution_ms, command_text);
                }
            } catch (Exception e) {
                Log.DebugFormat ("Exception executing command: {0}", command_text ?? command);
                Log.Exception (e);
                execution_exception = e;
            }

            // capture the text
            string raise_text = null;
            if (raise_command_executed && execution_ms >= raise_command_executed_threshold_ms) {
                raise_text = Text;
            }

            finished_event.Reset ();
            finished = true;

            if (raise_command_executed && execution_ms >= raise_command_executed_threshold_ms) {
                var handler = CommandExecuted;
                if (handler != null) {

                    // Don't raise this on this thread; this thread is dedicated for use by the db connection
                    ThreadAssist.ProxyToMain (delegate {
                        handler (this, new CommandExecutedArgs (raise_text, execution_ms));
                    });
                }
            }
        }
Example #34
0
        public bool Save()
        {
            var response = Connection.Execute(@$ "INSERT INTO {TableName()}(Marca,Ano,Modelo,Placa,Tipo,Valor) VALUES(@Marca,@Ano,@Modelo,@Placa,@Tipo,@Valor)", this);

            return(response == 1);
        }
Example #35
0
        public override Lfx.Types.OperationResult Guardar()
        {
            qGen.TableCommand Comando;

            if (this.Existe == false)
            {
                Comando = new qGen.Insert(this.Connection, this.TablaDatos);
                Comando.Fields.AddWithValue("fecha_ingreso", qGen.SqlFunctions.Now);
                Comando.Fields.AddWithValue("id_sucursal", Lfx.Workspace.Master.CurrentConfig.Empresa.SucursalActual);
            }
            else
            {
                Comando             = new qGen.Update(this.Connection, this.TablaDatos);
                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
            }

            Comando.Fields.AddWithValue("id_persona", this.Cliente.Id);
            if (this.Tipo == null)
            {
                Comando.Fields.AddWithValue("id_tipo_ticket", null);
            }
            else
            {
                Comando.Fields.AddWithValue("id_tipo_ticket", this.Tipo.Id);
            }
            if (this.Encargado == null)
            {
                Comando.Fields.AddWithValue("id_tecnico_recibe", null);
            }
            else
            {
                Comando.Fields.AddWithValue("id_tecnico_recibe", this.Encargado.Id);
            }
            Comando.Fields.AddWithValue("prioridad", this.Prioridad);
            Comando.Fields.AddWithValue("nombre", this.Nombre);
            Comando.Fields.AddWithValue("descripcion", this.GetFieldValue <string>("descripcion"));
            Comando.Fields.AddWithValue("estado", this.Estado);
            Comando.Fields.AddWithValue("articulos_descuento", this.DescuentoArticulos);
            Comando.Fields.AddWithValue("entrega_estimada", this.FechaEstimada);
            Comando.Fields.AddWithValue("entrega_limite", this.FechaLimite);
            Comando.Fields.AddWithValue("presupuesto", this.Importe);
            if (this.Presupuesto == null)
            {
                Comando.Fields.AddWithValue("id_presupuesto", null);
            }
            else
            {
                Comando.Fields.AddWithValue("id_presupuesto", this.Presupuesto.Id);
            }
            if (this.Factura == null)
            {
                Comando.Fields.AddWithValue("id_comprob", null);
            }
            else
            {
                Comando.Fields.AddWithValue("id_comprob", this.Factura.Id);
            }
            Comando.Fields.AddWithValue("obs", this.Obs);

            this.AgregarTags(Comando);

            this.Connection.Execute(Comando);
            this.ActualizarId();

            if (this.RegistroOriginal != null && this.RegistroOriginal["estado"] != this.Registro["estado"])
            {
                this.AgregarComentario("Actualización de Estado: " + Lbl.Tareas.Estado.TodosPorNumero[this.Estado].ToString());
            }

            if (this.Articulos != null && this.Articulos.HayCambios)
            {
                qGen.Delete EliminarArticulos = new qGen.Delete("tickets_articulos");
                EliminarArticulos.WhereClause = new qGen.Where("id_ticket", this.Id);
                this.Connection.Execute(EliminarArticulos);

                int i = 1;
                foreach (Lbl.Comprobantes.DetalleArticulo Det in this.Articulos)
                {
                    qGen.Insert InsertarArticulo = new qGen.Insert(Connection, "tickets_articulos");
                    InsertarArticulo.Fields.AddWithValue("id_ticket", this.Id);
                    if (Det.Articulo == null)
                    {
                        InsertarArticulo.Fields.AddWithValue("id_articulo", null);
                        InsertarArticulo.Fields.AddWithValue("nombre", Det.Descripcion);
                    }
                    else
                    {
                        InsertarArticulo.Fields.AddWithValue("id_articulo", Det.Articulo.Id);
                        InsertarArticulo.Fields.AddWithValue("nombre", Det.Articulo.Nombre);
                    }

                    InsertarArticulo.Fields.AddWithValue("orden", i++);
                    InsertarArticulo.Fields.AddWithValue("cantidad", Det.Cantidad);
                    InsertarArticulo.Fields.AddWithValue("precio", Det.Unitario);
                    Connection.Execute(InsertarArticulo);
                }
            }

            return(base.Guardar());
        }
            public override async Task <Response> Handle(Request request)
            {
                var response     = new Response();
                var composeMesec = request.Mesec;


                var razlika = Convert.ToInt64(request.SostojbaNova) - Convert.ToInt64(request.SostojbaStara);

                var brojClenovi = Connection.Query <int?>(@"Select BrojClenovi 
                    From Komunalecjpk.dbo.LokacijaFizickiLica 
                    where Vidkorid=@Vidkorid and LokacijaID=@LokacijaID and KorisnikID=@KorisnikID and ReonID=@ReonID",
                                                          new { Vidkorid = request.Vidkorid, LokacijaID = request.LokacijaID, KorisnikID = request.KorisnikID, ReonID = request.ReonID }).FirstOrDefault();


                var waterCounterItem = Connection.Query <Reons.GetAllDataFromReon.Response.WaterCounterListItem>(waterCounterListItemQuery, new
                {
                    YearMonth  = request.Mesec,
                    ReonId     = request.ReonID,
                    VidKorID   = request.Vidkorid,
                    KorisnikID = request.KorisnikID,
                    LokacijaID = request.LokacijaID,
                    Broilo     = request.Broilo
                }).FirstOrDefault();

                if (waterCounterItem != null && (waterCounterItem.SostojbaNova != "0" && waterCounterItem.SostojbaNova != null))
                {
                    response.Message = "Состојбата не е зачувана бидејќи веќе постои за овој месец";
                    return(response);
                }

                if (string.IsNullOrEmpty(request.SostojbaNova))
                {
                    response.Message = "Полето нова состојба е задолжително";
                }
                else
                {
                    var korisnikInfo = Connection.Query <KorisnikInfo>(korisnikInfoQuery, new { KorisnikId = request.KorisnikID }).FirstOrDefault();
                    var parameters   = new
                    {
                        Vidkorid                   = request.Vidkorid,
                        KorisnikID                 = request.KorisnikID,
                        LokacijaID                 = request.LokacijaID,
                        Broilo                     = request.Broilo,
                        Mesec                      = composeMesec,
                        SostojbaStara              = request.SostojbaStara,
                        SostojbaNova               = request.SostojbaNova,
                        Razlika                    = razlika.ToString(),
                        ReonID                     = request.ReonID,
                        UlicaID                    = korisnikInfo != null ? korisnikInfo.UlicaID : 1,
                        Broj                       = korisnikInfo != null?korisnikInfo.Broj.ToString() : "0",
                                              Vlez = korisnikInfo != null ? korisnikInfo.Vlez : "0",
                                              stan = korisnikInfo != null?korisnikInfo.Broj.ToString() : "0",
                                                         BrClenovi     = brojClenovi != null ? brojClenovi : 0,
                                                         Datum         = DateTime.UtcNow,
                                                         SlikaSostojba = "'" + request.SlikaSostojba + "'",
                                                         Lat           = request.Lat,
                                                         Long          = request.Long
                    };
                    var result = Connection.Execute(waterCounterUpdateQuery, parameters);

                    response.IsSucces = result == 1;
                }

                return(response);
            }