예제 #1
0
        public int Add(JobTicket jt, string currentUser)
        {
            try {
                using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
                {
                    conn.Open();
                    var result = conn.Query<int>(@"
                    insert into invoice.JobTickets(CompanyId,ClientCompanyId,JobDate,DeliveryDate,Quantity,[Weight],Milage,Toll,FuelSurcharge,
                                                    MiscFee,TotalCharge,WaitTime,PickupFrom,DeliverTo,Instruction,ServiceType,
                                                    DeliveryAgent,POD,Comments,CreatedBy,CreatedAt,PickupFromContact,PickupFromPhone,DeliverToContact,
                                                    DeliverToPhone
                                                    )
                                           values(@CompanyId,@ClientCompanyId,@JobDate,@DeliveryDate,@Quantity,@Weight,@Milage,@Toll,@FuelSurcharge,
                                                    @MiscFee,@TotalCharge,@WaitTime,@PickupFrom,@DeliverTo,@Instruction,@ServiceType,
                                                    @DeliveryAgent,@POD,@Comments,@CreatedBy,getutcdate(),@PickupFromContact,@PickupFromPhone,@DeliverToContact,
                                                    @DeliverToPhone
                                                    );
                                           SELECT SCOPE_IDENTITY()

                   
                                            ", jt);

                    return result.FirstOrDefault();
                }
            }
            catch(Exception ex)
            {
                logger.Fatal(ex);
                return 0;
            }
        }
예제 #2
0
        public int Update(JobTicket jt)
        {
            try
            {
                using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
                {
                    conn.Open();
                    var result = conn.Query<int>(@"
                                        update invoice.JobTickets
                                        set ClientCompanyId = @ClientCompanyId
                                            ,JobDate = @JobDate
                                            ,DeliveryDate = @DeliveryDate
                                            ,Quantity = @Quantity
                                            ,[Weight] = @Weight
                                            ,Milage = @Milage
                                            ,Toll = @Toll
                                            ,FuelSurcharge = @FuelSurcharge
                                            ,MiscFee = @MiscFee
                                            ,TotalCharge = @TotalCharge
                                            ,WaitTime = @WaitTime
                                            ,PickupFrom = @PickupFrom
                                            ,DeliverTo = @DeliverTo
                                            ,Instruction = @Instruction
                                            ,ServiceType = @ServiceType
                                            ,DeliveryAgent = @DeliveryAgent
                                            ,POD = @POD
                                            ,Comments = @Comments
                                            ,ModifiedBy = @ModifiedBy
                                            ,ModifiedAt = getutcdate()
                                            ,PickupFromContact = @PickupFromContact
                                            ,PickupFromPhone = @PickupFromPhone
                                            ,DeliverToContact = @DeliverToContact
                                            ,DeliverToPhone = @DeliverToPhone
                                        where JobTicketId = @JobTicketId
                                            ", jt);

                    return result.FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                logger.Fatal(ex);
                return 0;
            }
        }